Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

302
Vistas
Axios multiple then's

So I have a problem, I want so that this Axios returns me second then, and it doesn't work, and I can't understand why. So this second then returns me undefined, but I wanted to get ID from that or any data, any suggestions? I checked some other posts, they seemed to have the same writing, but for me it just doesn't work, help pls:)

If you want to check Axios, at the end write ?q=Grimm (for example). So the full page is: https://api.tvmaze.com/singlesearch/shows?q=Grimm

      .get('https://api.tvmaze.com/singlesearch/shows', {
        params: {
          q: id,
        },
      })
      .then((res) => setOneShow([res.data]))
      .then((res) => console.log(res));
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

In a .then() chain, the second then block gets data returned from the first then block.

In your case, to get the same data in the second then block, alter your code as:

  axios.get("https://api.tvmaze.com/singlesearch/shows", {
        params: {
          q: id
        }
      })
      .then((res) => {
        console.log("1", res);
        return res;
      })
      .then((res) => console.log("2", res));
  }
over 4 years ago · Santiago Trujillo Denunciar

0

Check this lessons: Arrow Functions, Promises. You are calling and returning setOneShow() in your first .then() method, not res. How it should looks like:

axios.get('https://api.tvmaze.com/singlesearch/shows', {
   params: {
     q: id,
   },
 })
 .then((res) => {
   setOneShow([res.data]);
   return res;
 })
 .then((res) => {
   console.log(res);
 });
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda