Wanderlust Project - step 17 | console 410 error

Hello everyone!

I have a problem with step 17 and I don’t manage to figure out where is.

Instructions are: Log venues to the console and see what the API sent back. There should be an array with the number of objects you selected in the limit parameter. You’ll only want the venue property inside of these objects. Use .map() to save these venues to the venues array from the previous step.

Add .map(parameter => parameter.valueToStore) to the end of the code from the previous step.

I logged venues to the console, but I don’t receive any API. Instead, I got this error:

[Error] Failed to load resource: the server responded with a status of 410 () (explore, line 0)

main.js:24 GET https://api.foursquare.com/v2/venues/explore?near=%20New%20York&limit=10&client_id=VNYRYXFYC53MASG1U2JGRO1VP4QUDY3BAE5EROZ2AGVYJ1IW&client_secret=’ '&v=20211130 410

Here’s my code:

// Foursquare API Info const clientId = ''; const clientSecret = ''; const url = 'https://api.foursquare.com/v2/venues/explore?near='; // OpenWeather Info const openWeatherKey = '77e2344ff307c644e408d7cfd4ae2221'; const weatherUrl = 'https://api.openweathermap.org/data/2.5/weather'; // Page Elements const $input = $('#city'); const $submit = $('#button'); const $destination = $('#destination'); const $container = $('.container'); const $venueDivs = [$("#venue1"), $("#venue2"), $("#venue3"), $("#venue4")]; const $weatherDiv = $("#weather1"); const weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; // Add AJAX functions here: const getVenues = async () => { const city = await $input.val(); const urlToFetch = `${url}${city}&limit=10&client_id=${clientId}&client_secret=${clientSecret}&v=20211130`; try { const response = await fetch(urlToFetch); if (response.ok) { const jsonResponse = await response.json(); console.log(jsonResponse); const venues = jsonResponse.response.groups[0].items.map(item => item.venue); console.log(venues); return venues; } } catch (error) { console.log(error) } } const getForecast = () => { }

Thank you!

1 Like

The API gives this response: Usage of the V2 Places API has been deprecated for new Projects. Please see our updated documentation for V3 for more details:

Seems like the exercise is designed for V2 of API. We can try to tag @lilybird to see if she can bring it to someone’s attention to update exercise for the new API since old one is deprecated for new projects. I also recommend to edit your post and delete the client-secret.

1 Like

Hi @stefisinca3621512529 and @mike7127143742! Based on codecademy’s instructions, your code is correct! However, the version of Foresquare’s API used in this project has since been deprecated. I found this forum post here on codecadmy first and used @wfarat 's response to resolve and understand the issue myself.

TLDR - To fo fix the issue, you need to do two things:

1. Generate an an API key for your project on ForSquare’s developer portal. This is what that should look like:

2. Change the part of your code where you’re making a get request to the ForSquare API to this:

const options = {method: 'GET', headers: {Accept: 'application/json', Authorization: 'API KEY'}};
const urlToFetch = `https://api.foursquare.com/v3/places/search?near=${city}&limit=10`
const response = await fetch(urlToFetch, options)

The longer explanation:

If you were to run and log the error of your fetch code locally (I did this in node), you’ll get something like this error message:

  meta: {
    code: 410,
    errorType: 'deprecated',
    errorDetail: 'Usage of the V2 Places API has been deprecated for new Projects. Please see our updated documentation for V3 for more details: https://docs.foursquare.com/reference',
    requestId: '61cc6f26aacc462cbc8dc579'
  response: {}

In other words, your code would probably have worked if you had registered this Project prior to V2 of the API being deprecated. However, ForSquare now wants you to use their updated API.

The new Version of the API does not map 100% to the older version that the project instructions are based on. There is no longer an “explore” for “venues” endpoint. Instead, the closest thing seems to be “search” for “places”. You can find the details on it here. The new endpoint is https://api.foursquare.com/v3/places/search. The query params for the url also change slightly. limit and city are still needed, but you need to remove the client_id, client_secret and v parameters from the URL.

v's functionality is not supported from by this endpoint. We remove the other two parameters because this version of the API handles authorization via the Authorization: 'API KEY' key-value pair that’s nested in the init object, options. This object is the second argument that we then pass to fetch. You can see mdn’s documentation on fetch for more details on this.

Hope that helped!


Thank you for writing this solution. It definitely helped!
Cheers! :slight_smile:

1 Like