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

276 points
554ad2eee39efe538f000204_786038148
Submitted by
Ben L.
over 3 years ago

What's wrong here?

Hi everyone, thanks for reading.

This is my code;

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.codecademy.com/doesnt_exist2", false);
xhr.send();
// Add your code below!
xhr.status();
console.log(xhr.status);

The reason I put xhr.open("GET", "http://www.codecademy.com/dosent_exist2...was because dosent_exist does exist!

Thanks again, Ben


3 votes

Best answer

permalink

This works!

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.codecademy.com/doesnt_exist2", false);
xhr.send();
// Add your code below!
console.log(xhr.status);
xhr.status();

276 points
554ad2eee39efe538f000204_786038148
Submitted by
Ben L.
over 3 years ago

2 Comments

Picture Adnan Manzoor over 3 years ago

Does NOT work anymore

51d0bff3282ae36a3e00d5c4_278476807 Jordy Vialoux almost 3 years ago

Can someone explain how a log works BEFORE a method is called?!??


0 votes

permalink

I don't know that anything is wrong here - I think it is a Codecademy bug. I ran into the same thing and then left and came back and it worked?!?!?!

914 points
Beba27ce9b14818200c4f4aae575c217?s=140&d=retro
Submitted by
javapuzzler
over 2 years ago


0 votes

permalink

It says we need to call the status but you don't actually have to. It ran with just the console log surprisingly.

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.codecademy.com/doesnt_exist", false);
xhr.send();
// Add your code below!
console.log(xhr.status);

564 points
Picture
Submitted by
Jason C Luu
over 2 years ago


0 votes

permalink

*Something like this, TRY IT OUT *

var xhr = new XMLHttpRequest();
xhr.open("GET", "https://www.codecademy.com/doesnt_exist", false);
xhr.send();
// Add your code below!
console.log(xhr.status);
xhr.status();

1233 points
566354cc937676913a000061_638238020
Submitted by
DAGIROV Djamal
almost 2 years ago