0

I'm trying to return the response from an API call but all I'm getting is a lousy promise. When I log the obj returned from fetchProducts and setProducts using useState I'm getting undefined

async function fetchProducts() {
const url = 'http://127.0.0.1:8000/products'
const obj = await (await fetch(url)).json();
return obj
}
Andy
  • 61,948
  • 13
  • 68
  • 95
J. Doe
  • 571
  • 1
  • 10
  • 24

0 Answers0