I want to navigate to the related list of accounts with click of the button in LWC.
But when I click on the button I am getting the below error :
Error in $A.getCallback() [Cannot read property 'errors' of undefined]
NavigatetoRelatedlist.js
import { LightningElement, api } from 'lwc';
import {NavigationMixin} from 'lightning/navigation';
export default class navigateToRelatedList extends NavigationMixin(LightningElement) {
@api recordId;
navigateRelatedListView() {
this[NavigationMixin.Navigate]({
type: 'standard__recordRelationshipPage',
attributes: {
recordId: this.recordId,
objectApiName: 'Account',
relationshipApiName: 'Contacts',
actionName: 'view'
},
});
}
}
NavigatetoRelatedlistHtml
<template>
<lightning-card title="Navigate to Related List View">
<lightning-button variant="brand" label="Related List View"
onclick={navigateRelatedListView}></lightning-button>
</lightning-card>
</template>
Can you help me why i am getting the above error . Do i need to pass recordID