Friday 24 May 2019

Node js json object getting undefined on api call when accessing values within object

So i am doing a nested api call using axios and I am getting a nested json object returned. Every time i try to access values within the nested json object I keep getting undefined heres an exampleapp.get('example/url){try{axios.get('api/url',{auth:{username: 'user",password:"password"},headers:{'Content-type':'application/json; charset=utf-8'}}).then(function(response){var examplePasrse = response.data.resultconsole.log(exampleParse.user_name)}// end of try}// end of get api callAlso i do have body parser enabled in my app and the object returned if just printing data"result": user_name

Submitted May 24, 2019 at 05:57PM by codinginsomnia

No comments:

Post a Comment