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

229
Views
No obtener respuesta con la llamada http GET en prortactor

Llamo a una API GET en mi suite de automatización pero no obtengo respuesta. La misma API funciona desde el cartero. Tengo un montón de console.log que no se imprimen. No hay errores también. A continuación se muestra el fragmento.

 var deferred = protractor.promise.defer(); var options = { method: "GET", hostname: hostname, port: 8080, path: '/v1/fis/'+fiId+'/businessCustomers/'+userAuthId+'/approvals', headers: { 'authorization': 'testclient', 'content-type': 'application/json', 'accept': 'application/json', } }; var req = http.request(options, function (response) { browser.sleep(1000); console.log('headers are:', options); console.log('hostname is: ', hostname); browser.sleep(1000); console.log('STATUS for approval API : ' + res.statusCode); var chunks = []; response.on("data", function (chunk) { console.log('in chunk block::'); chunks.push(chunk); }); response.on("end", function () { var body = Buffer.concat(chunks); var finaljson = JSON.parse(body.toString()); console.log('finaljson is:****', finaljson); successCallBack(finaljson.SuccessResponse); }); }); req.end(); return deferred.promise; };``` Any insights will be helpful. TIA!
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba algo como esto en su lugar. Debería funcionar mejor. Omití los mensajes de console.log para simplificar, pero puede agregarlos fácilmente donde los necesite.

 function myFunction() { return new Promise(resolve, reject) { const options = { method: "GET", hostname: hostname, port: 8080, path: '/v1/fis/'+fiId+'/businessCustomers/'+userAuthId+'/approvals', headers: { 'authorization': 'testclient', 'content-type': 'application/json', 'accept': 'application/json', } }; http.get(options, (res) => { let rawData = ''; res.on('data', (chunk) => { rawData += chunk; }); res.on('end', () => { try { const finaljson = JSON.parse(rawData); resolve(finaljson.SuccessResponse); } catch (e) { reject(e.message); } }); }).on('error', (e) => { reject(e); }); } }

Y luego simplemente lo llamarías usando myFunction().then((successResponse) => { // do stuff })

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!