Fetch() GET Requests III (4 of 17)


#1

Hi

I’m receiving an error stating: ‘Did you chain .then to fetch() and include response as a parameter?’

This is the syntax:

const getSuggestions = () => {
const wordQuery = inputField.value;
const endpoint = url + queryParams + wordQuery;
fetch(endpoint).then(function success(response) {})
}

And it’s the fetch part that is bringing back the error

Any Idea where I may be going wrong?

Link to the exercise is here (if you need it): https://www.codecademy.com/courses/intermediate-javascript-requests/lessons/requests-ii/exercises/fetch-get-requests-iii?action=resume_content_item&course_redirect=introduction-to-javascript


#2

Not sure if this will help…

  fetch(endpoint).then(response => {
    if (response.ok) {
      return response.json();
    }
  //... throw...

#3

This is what it is now from the time of writing (please see below)

// AJAX function
const getSuggestions = () => {
const wordQuery = inputField.value;
const endpoint = url + queryParams + wordQuery;
fetch(endpoint).then(response => {
if (response.ok) {
return response.json();
}
}

And the 6th check box is still crossed out


#4

Check the hint for step 6. Looks like you will leave the function block empty until the next step.

If you’ve been on this problem for awhile, itmay be necessary to refresh.


#5

Okay as soon as I hit refresh I’ve apparently done all the tasks (I should probably call it a day and come back again in the morning) :joy:

Thanks again for your help!