[Vuejs]-Vue.js, VueX โ€“ cannot render data from API in a component

1๐Ÿ‘

You probably need to set an empty array ([]) as an initial value to state.data.rides instead of null.

Another option will be to check that rides is truthy in your getters.
Something like:

 if (rides) {
   rides.sort(( a, b) => {
     return new Date(a.date) - new Date(b.date);
   });
  }
  return []

0๐Ÿ‘

I was able to resolve my problem and it turns out I made a mistake. I completely forgot I set state.data.rides = null instead of an empty array state.data.rides = null, which would explain why the array was empty. It was a legacy code I had ๐Ÿ™‚

Leave a comment