Error: afterRender threw an error in ‘c:viewRecord’ [Cannot read property ‘fields’ of undefined]

If you are new and learning LWC , you might face this error.
I was doing everything right but still the error pop’s up and I have struggled to find the answer. It took me few days to realize what can be an issue

lwc error

 

Solution:
When you trying to access the data , it might return the null value and therefore undefined error is returned.

To overcome this you need to put a check on the data.

Example:
if(this.account.data){
        return this.account.data.fields.Name.value;
      }
     return undefined;

Error OAUTH_APP_ACCESS_DENIED connecting Postman to Salesforce

After inserting all the correct information , if you are unable to Generate new access token and receiving following error OAUTH_APP_ACCESS_DENIED.

You have to enable users to Self-authorize

Setup >> Manage Connected Apps[Lightning]/ Connected Apps under Manage Apps[ Classic] >> Edit against connected app >> Select All Users may self-authorize in permitted users picklist

Connected apps

You are all set. Go ahead and try again and you will be prompted with allow window