Xhr get request ||| chapter

when i type a word in the last task of the project that’s nothing execute in the fieldResponse indespite i finish all the task with success please can someoene help me then this is my code :


// Information to reach API

const url = 'https://api.datamuse.com/words?';
const queryParams = 'rel_rhy='


// Selecting page elements
const inputField = document.querySelector('#input');
const submit = document.querySelector('#submit');
const responseField = document.querySelector('#responseField');

// AJAX function
const getSuggestions = () => {
const wordQuery = inputField.value;
const endpoint = url + queryParams + wordQuery;
const xhr = new XMLHttpRequest();
xhr.responseType = 'json';
xhr.onreadystatechange = () => {
  if(xhr.readyState === XMLHttpRequest.DONE) {
    renderResponse(xhr.response)
  }
  xhr.open('GET', endpoint);
  xhr.send()
}
}

// Clear previous results and display results to webpage
const displaySuggestions = (event) => {
  event.preventDefault();
  while(responseField.firstChild){
    responseField.removeChild(responseField.firstChild);
  };
  getSuggestions();
}

submit.addEventListener('click', displaySuggestions);

Is there a link to the course/lesson for this? Is this React?

this is the link for the course :
https://gist.github.com/6ecf08b1d6500a12d6abc134b028fc30

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.