Wanderlust - getting CORS errors at step 12

Hello,

I am stuck on stage 12 of the Wanderlust project. From what I can tell, I have done everything correctly (the hints are very prescriptive) but I repeatedly get errors in the console pertaining to CORS when I try to run.

image

I’ve tried various permutations and combinations around url, which from forum browsing seemed to be the source of the issue, but to no avail. I have also even copied someone else’s complete code but still have the same issue at this step.

My current code is:

// Foursquare API Info
const foursquareKey = 'redacted=';
const url = 'https://api.foursquare.com/v3/places/search?near=';

// OpenWeather Info
const openWeatherKey = 'redacted';
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=10`;
  try {
    const response = await fetch(urlToFetch, options);
    if(response.ok){
      console.log(response);
    }
  }catch(error){
    console.log(error);
  }  
};

Thanks in advance for your help!