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

174
Views
Obtener solicitud debe devolver el valor de cadena y asignar a una variable

Aquí están mis métodos:

 function RequestGet(options, url){ fetch(url, options).then(function(response){ return response.json(); }).then(function(value) { data = JSON.stringify(value) console.log(data) }).catch(function() { console.log("fail") }) } function GetUUID(){ data = RequestGet() uuid = [] data2 = data.results[0].groups groupLength = data2.length for (i = 0; i < groupLength; i++){ uuid[i] = data2[i].uuid } uuidString = uuid.toString() console.log(uuidString) }

Necesito RequestGet para devolver la salida de 'datos' (que puedo ver con console.log(data)) para poder usar el diccionario en la función GetUUID a continuación para obtener una clave específica (clave que estoy buscando es uuid).

Solo necesito poder pasar la respuesta GET al método GetUUID.

Actualmente devuelve "Indefinido"

Gracias.

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

0

Debe devolver una Promesa de su RequestGet . Prueba esto:

 function RequestGet(options, url){ return fetch(url, options).then(function(response){ return response.json(); }).then(function(value) { data = JSON.stringify(value) console.log(data) return data; }).catch(function() { console.log("fail") }) } async function GetUUID(){ data = await RequestGet() uuid = [] data2 = data.results[0].groups groupLength = data2.length for (i = 0; i < groupLength; i++){ uuid[i] = data2[i].uuid } uuidString = uuid.toString() console.log(uuidString) }
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!