axios.request(options).then(function (response) {
console.log(response.data.destination);
}).catch(function (error) {
console.error(error);
});
i am using axios library to retrieve data from an API which return below json object.
"data": Object {
"data": Object {
"at_dstn": false,
"at_src": true,
"at_src_dstn": true,
"awaiting_update": false,
"destination": "INDB",
"ir_train_name": "JODHPUR - INDORE Ranthambore SF Express",
"is_run_day": true,
"journey_time": 975,
"new_message": "Train hasn't started yet. But all looks good.",
"notification_date": "2022-08-21",
"run_days": "MON,TUE,WED,THU,FRI,SAT,SUN",
"seo_train_name": "Intercity Express",
"source": "JU",
"spent_time": 0.13,
"std": "2022-08-21 05:00",
"success": true,
"title": "Train starts at 05:00",
"train_name": "JODHPUR - INDORE Ranthambore SF Express",
"train_number": "12466",
"train_start_date": "2022-08-21",
"upcoming_stations": Array [],
"user_id": 0,
},
"message": "Success",
"status": true,
"timestamp": 1661021331914,
},
in this json file, i want to retieve destination value which can be access by
response.data.destination
but it returns value as undefined. so is there somthing i am missing
CodePudding user response:
Axios returns the response with data as shown in your response. If you want to get the destination values use this.
response.data.data.destination