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

330
Views
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
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!