Wanderlust blocked by CORS policy

Hy!
I have some problems with my project i can’t really fix.My code is below and i always get this error:

Access to fetch at ‘blablahttps://api.foursquare.com/v3/places/nearby?near=madrid&limit=3’ from origin ‘blablahttps://e40b632cf9774003b7e59084201d2850.cc-propeller.cloud’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
main.js:30
GET //api.foursquare.com/v3/places/nearby?near=madrid&limit=3 net::ERR_FAILED 502
(i had to edit some part of the links cause i am new user and i can only have 2!)
I went to this website Place Search to check on the side if i write to Authorization my API key does it work but i still get that 502 Error! So i dont know if i type my API key wrong or i am missing something else. Any help is welcomed!

// Foursquare API Info const foursquareKey = 'myAPIkey'; const url = 'https://api.foursquare.com/v3/places/nearby?near='; // OpenWeather Info const openWeatherKey = 'myAPIkey'; 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 $placeDivs = [$("#place1"), $("#place2"), $("#place3"), $("#place4")]; const $weatherDiv = $("#weather1"); const weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; const options = { method: 'GET', headers: { Accept: 'application/json', Authorization: foursquareKey } }; // Add AJAX functions here: const getPlaces = async () => { const city = $input.val(); const urlToFetch = `${url}${city}&limit=3`; try{ const response = await fetch(urlToFetch, options); if(response.ok) { const jsonResponse = await response.json(); console.log(jsonResponse); const places = jsonResponse.results; return places; } }catch(error) { console.log(error); } };

Same issue. Have you figured out the solution?

I had an older version of the project with a different url for the foursquare stuff.
It has search instead of nearby. And it still seems to work, but I don’t know if that’s relevant to this problem.

const url = 'https://api.foursquare.com/v3/places/search' + '?near=';
  • Wanderlust project has been replaced with a new Film Finder project. I just finished film finder and it was much easier to deal with that API