Wanderlust project help

Hi there!

Currently I am on the Wanderlust project and since there are no help in the project such as a walktrough video or anything I got lost after some tasks…

Right now I’m at task 13 but it is not working as expected but I don’t find any errors in my code. Like this I can’t go on and just sitting like a zombie next to the monitor. If you can please help me out! Thanks a lot!!

Here is my code:

const clientId = 'xxxx';

const clientSecret = 'xxx';

const url = 'https://api.foursquare.com/v2/venues/explore?near=';

// OpenWeather Info

const openWeatherKey = 'xxxx';

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 = $input.val();

  const urlToFetch = `${url}${city}&limit=10&client_id=${clientId}&client_secret=${clientSecret}&v=20180101`;

  try {

    const response = await fetch(urlToFetch);

    if (response.ok) {

      console.log(response);

    }

  } catch(error) {

  }

}

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}</h2>`);

}

const renderForecast = (day) => {

  // Add your code here:

  

  let weatherContent = '';

  $weatherDiv.append(weatherContent);

}

const executeSearch = () => {

  $venueDivs.forEach(venue => venue.empty());

  $weatherDiv.empty();

  $destination.empty();

  $container.css("visibility", "visible");

  getVenues()

  getForecast()

  return false;

}

$submit.click(executeSearch);

Blockquote // Foursquare API Info

Hi

Make sure to format the code in your posts when you ask questions because this makes it more readable (especially for debugging), you’ll get help much quicker this way.

First press the Screen Shot 2021-01-03 at 1.42.27 PM button and then paste the code between the tick marks Screen Shot 2021-01-03 at 1.42.33 PM

thanks, i changed it.

What specifically isn’t working as expected?

In the tasks it suggest that it should return an url but there is nothing returned but no errors.

Log the response to the console. In the browser window with the Wanderlust page, enter a city in the search field and submit. Make sure that you have your own browser’s JavaScript console open so that you can see the response that is logged to the console.
14.

Notice that the response includes the URL you requested but doesn’t include the information you asked for. Copy and paste the URL into a new tab in your browser. It might be difficult to read, so try using an extension such as JSON View to parse the data. If you don’t want to use an extension, you can also try JSBeautifier. Examine the object.

for me there is nothing returned

Ok. I’m assuming you already checked your console and found no reply. I would but a few console.log statements before to try to pin it down. One before the if, one before the try, and maybe one in the catch.

The fact that there’s no errors means one of these logs should probably go through.

  try {
    const response = await fetch(urlToFetch);
    if (response.ok) {
      console.log(response);
    }

still it is not working. Codacademy is a great piece of junk. I am starting to believe.

What’s not working specifically? Did the console.logs not ouput anything? If so you should keep following the logic-trail back until you find a place where the code is running. This happens in code whether it’s CC or not. Debugging is one of the more fundamental of the technical skills to have in programming.

The difficulty in following books/tutorials/videos/lessons is that you don’t have ownership over the code so a lot of it is getting a feel for the structure and where to debug. If you write it all by yourself at first, it’s easier in a way to debug (but you don’t get the more specific structure that a tutorial would impose).

As with anything, it’s useful to have skill in both. One helps for individual projects, another helps for working in a team environment where you have to enter a pre-made code structure and work well (and debug) inside of that.