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

173
Vistas
Using data collected with axios later in the code

I am trying to collect a data with API with axios. But let's say I want to use this data later on the code but whenever I get out of the async code the returned data's status becomes pending. How to return data and store it to use whenever I want in code?

Here is the code:

const fetchData = async () => {
const response = await axios.get("http://www.omdbapi.com/", {
    params: {
        apikey: "a7aeae67",
        // s: `${searchBar.value}`
        s: "vam"

    }
})
}

console.log(fetchData())
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is the famous "blue function red function" argument. Once your code is doing something async it will always need to be accessed in async context.

So - it is impossible to access response from a non-async function and you would have to access it inside async functions by awaiting it in turn.

about 4 years ago · Juan Pablo Isaza 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