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

129
Views
¿Cómo enviar múltiples solicitudes de venta de axios en un solo método?

Quiero enviar varias solicitudes PUT en un solo método, pero no sé si es posible, porque toda la documentación y las respuestas en SO son solo para solicitudes GET.

 // vue script, this is one PUT request updateProduct() { const config = { headers: { Authorization: `Bearer ${localStorage.getItem("token")}` }, }; axios .put( "myapihere.com" + this.$route.params.id, { name: this.name, }, config ) .then(async (res) => { console.log(res); }) .catch((err) => { console.log(err); }); },

Quiero agregar 2 solicitudes PUT más en el método updateProduct . ¿Es posible usar Promise.all? y luego, ¿cómo envío el cuerpo a cada URL correspondiente? Agradezco toda ayuda, gracias.

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

0

 // vue script, this is one PUT request updateProduct() { const config = { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, "Content-Type": "application/json" }, }; // lets say you wanna use the following data to send to 3 requests const allNames = ["name1", "name2", "name3"]; // following lets say your url params that are corresponding to your eachrequests const allParamIds = ["11","12","13"] const allRequests = allNames.map((eachName, index) => { const currentName = eachName; const currentParamId = allParamsIds[index] const currentUrl = `myapihere.com/${currentParamId}` // you have to return as a promise return axios.put(currentUrl, body: JSON.stringify({name: currentName}), config) }) // Promise.all() takes an array as argument, allRequests is an array Promise.all(allRequests) .then((response) => { // response will be an array console.log("response is", response); }) .catch(err => console.error(err)) },

¡Avísame si te funcionó o no!

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!