search

Home  >  Q&A  >  body text

Get the return result of Axios Get request in Vue.js

<p>My project is a Vue.js project. I use Flask to handle the api. When I try to request using axios.get, my api returns an object Objet. Actually, when I try the same request in Postman, it works. It returns data. </p> <p>My code is here: </p> <pre class="brush:php;toolbar:false;"><script> import axios from 'axios' const URL = 'http://localhost:8080/' mounted(){ axios.get(URL "/KPI/get_category/1").then(response=>{ for (const data in response.data) { this.kalite.push(JSON.parse(JSON.stringify(response.data[data]))) } for(const data in this.kalite){ axios.get(URL "/KPI/get_last_input/" this.kalite[data] ['id']).then(response=>{ console.log("response " response) }) } }) } </script></pre> <p>The results I see on the console are: response[object object]</p>
P粉447785031P粉447785031463 days ago494

reply all(2)I'll reply

  • P粉980815259

    P粉9808152592023-08-26 16:48:22

    Using Axios, you should be able to get the JSON data via reponse.data.

    If you use fetch, await response.json() can solve the problem.

    You should be familiar with the Network tab in Devtools, where you can inspect responses and understand the data. In particular Check the details of the resource

    reply
    0
  • P粉920199761

    P粉9201997612023-08-26 00:12:31

    Try using console.log(response.data)

    reply
    0
  • Cancelreply