[Vuejs]-Vue data fetched object not available in setup()

0👍

This problem has nothing to do with the variable myOptions

setup() {
  async function load_data() {
     const response = await fetch("http://LOCALHOST:8080/supplier_overview");
     return await response.json();
  }
  //the function is async, 1 will be called after 2, so the result is empty
  load_data().then((response)=>{
     data.table=JSON.parse(response.result.data)
     //1
     data.columns=(response.result.columns)
  });
  //2
  console.log(data.columns)

}

Leave a comment