Skip to content Skip to sidebar Skip to footer

Fetch Api - Returned Variable Undefined

I am a bit of a newbie to ES6 Javascript and have been trying to write a module to grab some data from the FourSquare API using fetch() and stick the results into some list items.

Solution 1:

You have to return the result of fetch():

return fetch(apiURL)

Also, when you call the getVenuesNear function, you have to use the then method to access the result:

fourSquareInstance.getVenuesNear(locationSearchBox.value).then(venueHTML => {
  console.log(venueHTML);
});

Post a Comment for "Fetch Api - Returned Variable Undefined"