Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue JS returning [Object object] on console.log and Undefined on JSON.parse

So I am writing this Vue.JS code to display a data aquired by PHP from a server. The PHP returns a JSON object to the Vue and the VUE has to display it. My current code is:

  axiosPost();
}
function axiosPost()
{
 axios.post(
  './ConversationGetter.php',
  {
    function2call: 'getRecord',
    id: 1,
    access: this.accesstoken
  }

)
.then(response =>  {this.data=response.data;
console.log(response.data);
console.log("Response From VUE JS"+this.data);

})
.catch(error => {});
}

The Problem is, First console.log prints the Response data properly. But the second console.log displays the this:

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

If I use JSON.parse while displaying the data, it shows this:

undefined
like image 335
Shri Avatar asked Oct 19 '25 04:10

Shri


1 Answers

"+" operator converting as string in second console statement. Please change it to "," as below?

console.log("Response From VUE JS", this.data);
like image 114
Siva K V Avatar answered Oct 21 '25 18:10

Siva K V



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!