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

104
Views
¿Cómo borrar el caché de solicitudes después de intentar múltiples solicitudes en Cypress?

Aquí está mi código, paso una matriz de ID y para cada ID presiono la solicitud Api.

 for (let i = 0; i < 10; i++) { cy.request({ method: 'GET', url: `https://[API endpoint ]/api/v1/[requst]/${ids[i]}`, headers: { "authorization": token } }) .then((res) => { return usernames.push([{ value: res.body.instagrams[0].username }]) }) .then((res) => { return cy.wait(2000) }) }

Cada vez que ejecuto el código, para 2-3 solicitudes funciona bien y luego arroja un error como

 Uncaught Error: invalid payload

Puedo ver que mi URI es correcto y envío la solicitud correcta.

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

0

debe modificar su código para envolver todas las promesas pendientes en una matriz. Un fragmento modificado es el siguiente:

 async function processRequest(){ let result; let promises = []; for (let i = 0; i < 10; i++) { promises.push(cy.request({ method: 'GET', url: `https://[API endpoint ]/api/v1/[requst]/${ids[i]}`, headers: { "authorization": token } })) } result = await Promise.all(promises); for(let i = 0; i < 10; i++){ usernames.push([{ value: result[i].username }]) } }
about 4 years ago · Juan Pablo Isaza Report

0

Aquí cy.request no funciona correctamente con Promise. Ya sea mientras lo presiona para prometer una matriz, elimine cy.request() o simplemente manéjelo con javascript.

 async findUserName(ids, token) { let promise = [] let usernames = [] ids.forEach(id => { promise.push( fetch(`https://[host]/api/v1/[endpoint]/${id}`, { headers: { 'Content-Type': 'application/json', "authorization": token } }) .then((res) => { return res.json(); }) ) }) let result = await Promise.all(promise); result.forEach((data) => { usernames.push([{ value: data.instagrams[0].username }]) }) return usernames

}

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!