[Vuejs]-Vue data not updated in created()

0👍

Since it’s doing a request hit..the second console prints before the request is resolved. Try using async-await

async created() {
  await api.get_appointments()
      .then(appointments => {
          for (var i = 0; i < appointments.length; i++) {            
              this.tableOne.push(
                  {
                      tech: appointments[i].tech_name,
                      date: appointments[i].scheduled_date
                  }
              )
          }
          // console.log(this.tableOne);
      });
  // console.log(this.tableOne);
  },

Leave a comment