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

327
Vistas
async fetch function returning promise pending

So i have a fetch function that should return me a url from a api that i created. It kinda works, but the issue is instead of returning the URL it returns promise pending. I've used async-await so I don't know what could be causing the issue

   const getUser = async (id) => {
       let url = `http://127.0.0.1:8000/api/user/${id}/`
       const response = await fetch(url)
       const data = await response.json()
       return data.avatar
   }

    console.log(getUser(1))

This is the response from the API

{
    "id": 1,
    "email": "somemail@gmail.com",
    "username": "somewhattastydonut",
    "avatar": "https://somebucketname.s3.amazonaws.com/default.jpg"
}

I want it to return just the URL from the avatar but i don't know what I'm doing wrong for it to return promise pending

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