I am writing a program with php
laravel
and react.js
. But i am very new to these. Anyway in react
, i am sending a API request with ajax
.
like this:
const sendquery = {
"async": true,
"crossDomain": true,
"url": url,
"method": "POST",
"headers": {
"Authorization": "Bearer " + tkid,
"Accept": "application/json",
"Content-Type": "application/json",
},
"processData": false,
"data": query
};
$.ajax(sendquery).done(function (response) {
console.log('Survey Request :' + response);
});
There are another API requests that are printing nicely when i console.log()
because they are in array type. But this must be json
. I tested API with Postman everything is OK. But still i have output like this:
Survey Request :[object Object]
Can anyone please help ?
You can try with JSON.stringify(response)
but note that it doesn't work with all the types, see JSON.stringify doesn't work with normal Javascript array, for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With