[Vuejs]-Vue and data from REST API

2๐Ÿ‘

โœ…

You are getting this error, because when you are fetching data from axiosinstance, that time item.details is null, and when it tries to render it throws this error.

Once the api call is completed, it updates the the DOM and in turn re-renders the DOM, so you can see item.details.Title rendered.

You need to add a null check to prevent this error, which can be easily done using v-if, like follwoing:

template:
'<div>'+
  'Form with id = {{id}}'+
  '<br/>'+
  '<span v-if="item.details"> has title = {{item.details.Title}}'+
  '</span>' +
'</div>',
๐Ÿ‘คSaurabh

Leave a comment