0

Does anyone know how to insert the Query values, into the var data? (React.js)

let data = [];

  api.get('/').then(res => {
    console.log(res.data);
    data = res.data;
  })
  console.log(data);
  • Put `console.log` inside `then` block code. Another solution could be using async/await. – Pipe Jul 12 '22 at 16:35
  • 3
    Does this answer your question? [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Ivar Jul 12 '22 at 16:35

0 Answers0