I'm using the request package to send a post request to get an authToken, and then a get request to get an array of parcel objects so I can send it on to the rest of my app. When I log the body.parcels, it shows me several [Object, Object] items. I can't see the data inside of these objects, so I'm having trouble figuring out what the data is.
var options = {
uri: 'https://api.onetracker.app/auth/token',
method: 'POST',
json: {
email: this.config.username,
password: this.config.password,
},
};
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
const authToken = body.session.token;
const options = {
uri: 'https://api.onetracker.app/parcels',
method: 'GET',
json: true,
headers: {
'x-api-token': authToken,
},
};
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
let result = body.parcels;
console.log('Result: ' + result); // check
this.sendSocketNotification('ONETRACKER_RESULT', result);
}
});
}