[Vuejs]-(vuejs) Array undefined with axios and quasar

0👍

If you want to log it from your code (like in the .then promise, for example) you should do:

console.log(this.programmetoEdit);

Moreover, you are doing assignment in parallel of the job Axios is doing. Not after, as I guess you are expecting it to do.

You should drop all your stuff in the .then promise if you want it to happen after the this.programmeEdit=response.data part.

Like so (this will show the dialog WHILE loading the data/waiting for the API to respond):

    getProgramme ($id) {
    axios.get("http://localhost:80/api/programme/" + $id)
      .then(response => {
        this.programmeEdit=response.data;
        this.programmeEdit.id=this.programmetoEdit;
      });
      this.show_dialog= !this.show_dialog;
    }

Or like so (this will show the dialog AFTER loading the data/waiting for the API to respond):

    getProgramme ($id) {
    axios.get("http://localhost:80/api/programme/" + $id)
      .then(response => {
        this.programmeEdit=response.data;
        this.programmeEdit.id=this.programmetoEdit;
        this.show_dialog= !this.show_dialog;
      });
    }

Leave a comment