I've been attempting to generate multiple JSON objects by making an external call to the FourSquare API with different query parameters. However, my code is continuously returning a successful response code without any readable results. Here's the code snippet I'm trying to implement:
async function getPlaces(query, lat, lon, clientID, clientSecret, versionDate) {
const URL = `https://api.foursquare.com/v2/venues/search?client_id=${clientID}&v=${versionDate}&ll=${lat},${lon}&intent=browse&radius=10000&query=${query}&limit=10&client_secret=${clientSecret}`;
const response = await fetch(URL).catch(e => { console.log(e) });
const data = await response.json().catch(e => { console.log(e) });
return data;
}
Every time I invoke this function to create a JSON object like so
const beachData = getPlaces("beaches", lat, lon, clientID, clientSecret, versionDate);
The output appears as:
Promise { <pending> }
I also attempted using the following code with similar results
const beachData = getPlaces("beaches", lat, lon, fourSquareClientID, fourSquareClientSecret, versionDate).then(({ beachData }) => { beachData; });
If anyone can provide some guidance on what might be going wrong, it would be greatly appreciated. Ideally, I'd like to be able to call this function multiple times and receive several JSON objects that I can later combine for the front end response. Thank you!