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

802 points
51f0212d8c1ccc7b17005df8_607621929
Submitted by
MaliaC
almost 4 years ago

[bug, fixed] HTTP Status Codes - getting 200

My code looks right but I continue to receive this error: Oops, try again! Did you console.log(xhr.status)?
My code:

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

I just don't understand why it doesn't work.

EDIT:
Got it, the page they are currently using for this exercise is an actual page and will not let you pass unless you type something random like
http://www.codecademy.com/stephano.pewdiepie
in its place. Sorry to create a forum for nothing.

Reported to the Buggy Exercises group: http://www.codecademy.com/groups/buggy-exercises/discussions/5233bd1c80ff33183600292d


3 votes

permalink

Just change the text, I actually just deleted a letter but putting in something offensive such as hitler lives here should get you the 400

1343 points
E0d23686d0f2a1f68be3cdb60a4adc86?s=140&d=retro
Submitted by
Lewis Cowles
almost 4 years ago

1 Comment

Picture Michael Londeen almost 4 years ago

Clarification: If you run into this error, check the output window. If you are getting a status of 200, this means that you are successfully fetching a page that exists. The goal of this lesson is to receive a 404 response from the server for attempting to fetch a page that doesn't exist. To finish the Lesson: Change the page you are requesting in the the xhr.open statement to a page that does not exist.


1 vote

permalink

that works

664 points
Ec582d7d1ed0319e20999f46459957a0?s=140&d=retro
Submitted by
Milad
over 3 years ago


1 vote

permalink

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

THIS WORKS!!!!!!

630 points
E3380c5df4cd383562c9f1778638fafd?s=140&d=retro
Submitted by
AdityaSurve
about 3 years ago


0 votes

permalink

code is not working even if you remove doesnt exist and put in any crap value?
what is the bug in this exercise....someone plzz comment?
The code is correct now but I continue to receive this error: Oops, try again! Did you console.log(xhr.status)???????????????? i am getting 244 again and again?

577 points
5332af1252f863b50e00166b_307761762
Submitted by
Paras alpha whiskey 988
over 3 years ago


0 votes

permalink

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

But still the error "NetworkError: A network error occurred." in output, with the hint "Oops, try again. Did you console.log(xhr.status)?"

24 points
Picture
Submitted by
Adnan Manzoor
about 3 years ago

1 Comment

Ca0c5f90c155c3a3497874c42a136b78?s=140&d=retro Pontus Heggelund almost 3 years ago

I'm getting the same error. Doesn't get 404 whatever page I enter.


0 votes

permalink

I got around this by using the following code at the end:

if(xhr.status!=="404"){
console.log(404);
}

Not ideal...but I don't know what the bug is.

1849 points
Picture
Submitted by
Keith Blackburn
about 3 years ago