I am using Node.js and superagent for testing my server implementation. Using Superagent GET request is send and POSITIVE response is received using below CODE. My usecase to get and log only "id" (OUTPUT) value from the response message. How to extract "id" value from the response.
message Format: json
request.get(MyURL).then(res res => {
data = JSON.parse(res.text);
console.log(data);})
{ data:
[ { id: '35132df0-fa8c-42ec-80d7',
name: 'name1',
uri: '/xxxx/yyyy/35132df0-fa8c-42ec-80d7' } ],
status: 'ok'
}
Thank you
let foo = { data: [ { id: '35132df0-fa8c-42ec-80d7', name: 'name1', uri: '/xxxx/yyyy/35132df0-fa8c-42ec-80d7' } ], status: 'ok' }
console.log(foo.data[0].id)