Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
JSON value returned as undefined when we fetch JON.parse data present in the depth of JSON using javascript

Related to this post : Parsing JSON to object using JSON.parse

I am facing similar issue and using console.dir(responseData.data, { depth: null }) i am able to get full text for 'credApp' field. However, When i try to access the element like 'responseData.data.orderItems.credDecision.credApp' to validate it against another variable then I get 'credApp' value as undefined.

I am able to get the values till credDecision such as responseData.data.orderId. Is there anyway to resolve this issue. Any help is much appreciated.

here is the code:

const getResponseData = (url) => new Promise((resolve, reject) => {
http.get(url, res => {
const { statusCode } = res;
const contentType = res.headers['content-type'];
res.setEncoding('utf8');
let rawData = '';
res.on('data', (chunk) => { rawData += chunk; });
res.on('end', () => resolve({ statusCode, contentType, rawData }));
}).on('error', e => reject(e));
});

const responsePayload = await getResponseData(api_url+ orderNumber);

var responseData = JSON.parse(responsePayload.rawData);
console.dir(responseData.data, { depth: null });
var orderId = responseData.data.orders.externalOrderId;
var credApp = responseData.data.orderItems.credDecision.credApp;

Posting a sample part of api response since the response payload is large, I am trying to fetch OriginalOrderId and it is returned as undefined when I convert it into JSON and validated against another field:

"data": {
  ringId: '1',
  consumerId: '2',
  orderSummary: {
    guestCheckout: null,
    id: '1233'
    orders: [{
      orderId: 'ABC1233',
      orderType: '1'
    }],
    dateCreated: '2021-10-18T16:28:46.964Z',
    createdBy: 'User1'
  },
  orders: [{
    OriginalOrderId: '9693'
  }]
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!