I have been following the instructions for this exercise, but when I write the code for the if statement (see below) I get the above error message. I’ve added in the code that I have done so far. Hope you can help me.
// Add AJAX functions here:
const getVenues = async() => {
const city = input.val();
const urlToFetch = `{url}{city}&limit=10&client_id={clientId}&client_secret=${clientSecret}&v=20200219`;
try {
const response = await fetch(urlToFetch);
if(response.ok){
const jsonResponse = await response.json();
console.log(jsonResponse);
}
catch (error)
{
console.log(error);
};
const venues =jsonResponse.response.groups[0].items;
console.log(venues);
}
Your catch is inside your try. Therefore you got the unexpected token Catch error. I don’t know how you implement indentation in your syntax but that would have aided you in this debugging.
// Add AJAX functions here:
const getVenues = async() => { // opens async
const city = input.val();
const urlToFetch = `{url}{city}&limit=10&client_id={clientId}&client_secret=${clientSecret}&v=20200219`;
try { // opens try
const response = await fetch(urlToFetch);
if(response.ok) { // opens if statement
const jsonResponse = await response.json();
console.log(jsonResponse);
} // closes if statement
// expects a closing } for try yet finds catch, causing the error
catch (error) { // opens catch
console.log(error);
}; // closes catch
const venues =jsonResponse.response.groups[0].items;
console.log(venues);
} // should close the async yet closes the try
2 Likes
It could very well be it was indented, and we simply can’t tell because of the lack of proper formatting. 
1 Like