DEV Community

Riccardo Pirani
Riccardo Pirani

Posted on

Undefinend response with axios

Hi I have a question about the following code, this code makes a rest call with axios to a server, the value returns correctly from the node.js server, that is, if I test the call with postman I have a response with the integer value however in this case the value is undefined what is it due to?

axios.post(apiBaseUrl+'/utente/login', payload,header).then(function (response) {

 console.log("\n Valore di response.data:"+response.data); //Undefinend?


} 
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
savagepixie profile image
SavagePixie

Are you sure that the response object has a property named data? Try logging the whole response and see what you get.

Collapse
 
hoxtygen profile image
Idowu Wasiu

By default axios response have a data property where all response are stored. Unless things have changed from the last time I used it. As you said, the whole response object should be logged to see its content.