[Vuejs]-Out of two functions, one can access variable's value, the other can't

1๐Ÿ‘

โœ…

As per looking at the console statement, function setLastUpdate is calling before the parseData function.
So, to make the lastUpdate property available for setLastUpdate, you need to call those functions asynchronously. You can create a single async function that will call both functions one by one and wait for the first to be executed. For example-

created() {
  this.init();
},

methods: {
  async init() {
    await this.parseData();
    await this.setLastUpdate();
  },
},

One more thing-

instead of-

this.items[0].items.title = this.lastUpdate;

It should be-

this.items[0].items[0].title = this.lastUpdate;

Because inner items is having an array of objects structure.

๐Ÿ‘คNeha Soni

Leave a comment