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

135
Views
How would I get a specific nested value from a fetch POST response?

I have made a POST request like this:

var myHeaders = new fetch.Headers();
        raw = "srvrwd-ui=useMe"

        var requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: raw,
        redirect: 'follow'
        };
        
        fetch("https://www.example.net", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));

In console it does print the result and it comes out like this

{"totalResponse":{"details":false},"address":{"number":"234"}}

I want to get the value of number and the methods I have used to extract it specifically is the following:

.then(result => console.log(result["number"]))

which returns undefined

.then(result => console.log(result.totalResponse.address.number))

returns undefined again.

Is there any way I could get the specific value?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are very close, totalResponse and address are two separate properties, so it would be

.then(result => console.log(result.address.number))

It would probably be beneficial for you to review this documentation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects as it will explain working with objects quite well.

about 4 years ago · Juan Pablo Isaza Report
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!