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
console.log('some string' + [someObject, someObject, etc])coerces the array of objects in this.data to be an array of strings, and objects as strings become'object Object'- i.,e ignore the second console.log, it is completely as expected, the data is correct - useconsole.log('some string', [someObject, someObject, etc])... notice the,instead of the+... and your console.log will be what you expected in the first place