This forum is now read-only. Please use our new forums at discuss.codecademy.com.

How to use APIs with JavaScript Forum

View Course » View Exercise

1471 points
51ed7806631fe92de60011b2_21743798
Submitted by
alexhansen_4ff9f84c4ad1920003035d9f_
over 4 years ago

Help!!!

this is my code:
// Add your code below this line!
var xhr = new XMLHttpRequest();
xhr.open("GET", "URL", false);
// Add your code above this line!

console.log(xhr.status);
console.log(xhr.statusText);


2 votes

permalink

There are two things that you appear to have overlooked.

The first if line 4. The second argument ought to be the URL which is the address to the server which we are making a request from. So in this example, the line should read:

xhr.open("GET", "http://www.codecademy.com", false);

Secondly, below this line, the exercise requires we .send() the request off to the server. This requires a line below line 4 which reads:

xhr.send()

I hope this helps

EDIT: I replaced the place holder "URL" with the actual URL used in the exercise (http://www.codecademy.com) as modecode suggested - that'll teach me to copy-paste and not read through :)

500 points
7ae0755f896bcfb39213d92666f231ef?s=140&d=retro
Submitted by
Jeshua Maxey
over 4 years ago

1 Comment

52642d9437ea79ab654d4066e7ac1ed9?s=140&d=retro modecode over 4 years ago

You might also want to replace URL with the one mentioned in the task


0 votes

permalink

Hey Alex - could you modify your title to be a little more descriptive? This way others will find help from Jeshuas excellent answer too :)

978 points
51649d3b4cdb759392000d3e_193280166
Submitted by
Linda Liukas
over 4 years ago