Skip to content
loading...

Undefinend response with axios

riccardopirani profile image rikidev github logo ・1 min read  

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?


} 
twitter logo DISCUSS (2)
Discussion
markdown guide
 

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

 

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.

Classic DEV Post from Apr 17 '19

What It Means To Be A Site Reliability Engineer

What it means to be a Site Reliability Engineer at Kenna Security.

rikidev profile image