Skip to content

not able to consume search api data

I am new in nodejs and I want to use /api/v1/search api to search the zip code to locatioin.

I am not able to use the location returned by the API.

const request = require('request');
request('<apiKey>', (err, res, body) => {
    if (err) { return console.log(err); }    

Output is


In curl it is giving the output but in nodeapi I am not able to use the location array.


You should follow the example given in docs. You are receiving JSON response in string from. Please parse the body object as JSON first and then use the result.