Wanderlust Project

Hello I am currently working through the Wanderlust project on the WebDev path. I will completely admit I am not yet full comprehending all the different concepts that are involved with this project. But I have made it to the point where they ask you to log the response from the API out to the console, to make sure you have a valid response. But when I do this I get a 400 error back. Did I do something wrong?

Here is a link to my Code: https://gist.github.com/codecademydev/d41c1e076c2e8dcc73a6a66a87ed1ad7

So I think I figured this out shortly after posting this question. However I would be interested to know why what I did fixed my issue. So when was having the 400 error issue I had the Const url variable set as follows:

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

All I add to do is delete the extra space that I had between the ? and the N in near.

any reason why that caused my issue and could someone farther explain the the ?near=’ does?

This is why the extra space in the URL caused your issue:
image

That space became a %20 when the full URL was requested, so the API for Foursquare didn’t know what you were requesting. Foursquare was specifically looking for the value of near, but it saw %20near.

As for what that ?near= part of the URL means, take a look at this cheatsheet from Codecademy
https://www.codecademy.com/learn/introduction-to-javascript/modules/intermediate-javascript-requests/cheatsheet
The section for ‘The query string in a URL’ explains what the query string is about. In this case, the value for near is something Foursquare looks for in order for it to know where you’re searching. If you take a look at the documentation for the Foursquare Explore API and you’ll find near: https://developer.foursquare.com/docs/api-reference/venues/explore/