XHR GET Requests IV and XHR Post Requests III

I have a question.
in XHR GET Requests IV step 5 theres .word method that I cant find, were is it?

 // Creates an empty array to contain the HTML strings
  let wordList = [];
  // Loops through the response and caps off at 10
  for(let i = 0; i < Math.min(res.length, 10); i++){
    // creating a list of words
    wordList.push(`<li>${res[i].word}</li>`);

Theres one similar in step 9 ( XHR Post Requests III): .shortUrl ?

const renderResponse = (res) => {
  // Displays either message depending on results
  if(res.errors){
    responseField.innerHTML = "<p>Sorry, couldn't format your URL.</p><p>Try again.</p>";
  } else {  
    responseField.innerHTML = `<p>Your shortened url is: </p><p> ${res.shortUrl} </p>`;
  }
}

thankfull for answers

https://www.codecademy.com/paths/build-web-apps-with-react/tracks/bwa-ajax-requests-and-api-interactions/modules/bwa-http-requests/lessons/requests-i/exercises/review-requests-i

there isn’t a word method, the response is very likely json has key/value pairs. You could log the entire response to insect it? For the GET exercise, you seem to have an array with objects. These objects have a word key.

in the post, you seem to get back a single object with shortUrl key (which has a value).

2 Likes

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