Get the return result of Axios Get request in Vue.js
P粉447785031
P粉447785031 2023-08-25 21:53:06
0
2
499
<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粉447785031
P粉447785031

reply all(2)
P粉980815259

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

P粉920199761

Try using console.log(response.data)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template