Wanderlust URL


#1

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

I keep getting the “request failed” message in my browser console. I don’t know why i’m getting that message. I believe it has something to do with the foursquare app i created. I don’t know if i’m including the correct url. Currently, i’m using the url that appear in the address bar for the wanderlust project which is “https://www.codecademy.com/courses/introduction-to-javascript/projects/wanderlust

What url should i be using. Also, below is my code just in case the url isn’t the problem.

// Foursquare API Info
const clientId = ‘XVZFCZTSFXX2XDAC3MPE223PZEREUNS53GEHCHPSP1OIJHVT’;
const clientSecret = ‘QDCZUINHI5P2ROBNLDOIBLFUNNPSXGHQZQHAU2KCOW4EBEKP’;
const url = ‘https://api.foursquare.com/v2/venues/explore?near=’;

// APIXU Info
const apiKey = ‘37c2c081a0fa444ca90ecabba85ccac2’;
const forecastUrl = ‘https://api.apixu.com/v1/forecast.json?key=’;

// Page Elements
const input = (’#city’);
const submit = (’#button’);
const destination = (’#destination’);
const container = (’.container’);
const venueDivs = [("#venue1"), ("#venue2"), ("#venue3"), $("#venue4")];
const weatherDivs = [("#weather1"), ("#weather2"), ("#weather3"), $("#weather4")];
const weekDays = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’];

// Add AJAX functions here:
const getVenues = async () => {
const city = input.val(); const urlToFetch = `{url}{city}&limit=10&client_id={clientId}&client_secret=${clientSecret}&v=20181127}`;

try {
const response = await fetch(urlToFetch);
if (response.ok) {
console.log(response);
}
else {
throw new Error(‘Request failed!’);
}
}
catch(error) {
console.log(error.message);
}
};

const getForecast = () => {

}

// Render functions
const renderVenues = (venues) => {
$venueDivs.forEach(($venue, index) => {
// Add your code here:

let venueContent = '';
$venue.append(venueContent);

});
destination.append(`<h2>{venues[0].location.city}`);
}

const renderForecast = (days) => {
$weatherDivs.forEach(($day, index) => {
// Add your code here:

let weatherContent = '';
$day.append(weatherContent);

});
}

const executeSearch = () => {
$venueDivs.forEach(venue => venue.empty());
$weatherDivs.forEach(day => day.empty());
$destination.empty();
$container.css(“visibility”, “visible”);
getVenues()
getForecast()
return false;
}

$submit.click(executeSearch)


#2

When you log in to FS, click your profile and -> My Apps. Then Edit in the upper right corner. There, my app url is: foursq

That works for me. I had your problem, but I think I found the solution in Codecademy’s notes somewhere when I reread it thoroughly. Does it help?


#3

That worked! Thank you soooooooooooooo much!!!


#4

Yes! Good luck with the exercise! :slight_smile: