I am working with node.js that runs on AWS lambda. As part of the logic there is an API call via axios
GET/POST/DELETE API.
The code looks like:
const response = await axios.get(url);
console.log(response); // **returns [object Object]**
And in case of console.log(JSON.stringify(response, null, 2));
will crash.
Here is the response schema of axios: https://github.com/axios/axios#response-schema
And also the example of how to log the inner properties of the response:
axios.get('/user/12345')
.then(function (response) {
console.log(response.data);
console.log(response.status);
console.log(response.statusText);
console.log(response.headers);
console.log(response.config);
});
I also read that the response object of the axios
is a POJO here.
But didn't find any explanation how to convert it to Object that can be strigified as full response object.