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

125
Views
¿Cómo obtendría un valor anidado específico de una respuesta POST de búsqueda?

He hecho una solicitud POST como esta:

 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));

En consola sí imprime el resultado y sale así

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

Quiero obtener el valor del number y los métodos que he usado para extraerlo específicamente son los siguientes:

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

que devuelve indefinido

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

vuelve indefinido de nuevo.

¿Hay alguna manera de que pueda obtener el valor específico?

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

0

Estás muy cerca, totalResponse y address son dos propiedades separadas, por lo que sería

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

Probablemente sería beneficioso para usted revisar esta documentación https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects ya que explicará cómo trabajar con objetos bastante bien.

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!