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

How to use APIs with JavaScript Forum

View Course

238 points
5509cb6f9113cb63d7000f89_662258226
Submitted by
Parker Smith
about 2 years ago

10/19 HELP??

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

^^ keeps asking me if I did "console.log(xhr.status)" ??


2 votes

permalink

Change http to https and then it works. According to the CodeAcademy blog, they recently transitioned to hhtps.
https://www.codecademy.com/blog/156-https

779 points
577478d83f07ff406d9bb7fe8cdf2da0?s=140&d=retro
Submitted by
Katie Taylor
almost 2 years ago

2 Comments

559dea5a76b8fea330000692_392433978 Amir Bazgir almost 2 years ago

Thanks Katie

Eca7d99d77604e8663d25a8ca40d1e4f?s=140&d=retro Aapo Saaristo almost 2 years ago

You can also simply remove the http: or https: part completely (as in "//codeacademy.com/doesnt_exist"), this will automagically use the same connection type the webpage was loaded with.

I really wish codeacademy would've fixed their course source code along with the transition to secured connections.


0 votes

permalink

Yeah I got the same, no matter how I did it. Even dragged the error and pasted the code, that didn't work either :s

530 points
559fa054d3292f619000024c_28196829
Submitted by
KW
almost 2 years ago


0 votes

permalink

try this:

var xhr = new XMLHttpRequest();
xhr.open("GET", "https://www.codecademy.com/doesnt_exist", false);
xhr.send();

// Add your code below!
console.log(xhr.status);

use https not http

394 points
5352dba6548c35eaa6002a7b_855482114
Submitted by
Michael A
almost 2 years ago


0 votes

permalink

Parker- your code worked fine for me. I just added a semicolon to the last line. HTH

80 points
718aacca112a185cf9e76d2878d4d18f?s=140&d=retro
Submitted by
jeffreybjohnson1gmail.com_55fad17b95
almost 2 years ago


-2 votes

permalink

this might be broken so
I typed console.log("404") to squeeze past the parser.

1229 points
21c121c5a0193f7afdd26d54f42044b1?s=140&d=retro
Submitted by
Impatient_5375d8d18c1ccc6f770017b9_d
about 2 years ago