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

How to use APIs with JavaScript Forum

View Course

626 points
38e3e8ba08c66d69ddb6c6dd3429032f?s=140&d=retro
Submitted by
mazohysta88
about 2 years ago

16/19 I spelled Codecademy right, it still doesn't work. - SOLVED

Hi, can anyone at all help? This is my code

// Add your code below this line!

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

xhr.send();

// Add your code above this line!

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

The error I get: Did you set xhr equal to new XMLHttpRequest(), then call xhr.open() with the arguments listed? Check the Hint if you need help!

And in the output screen: NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://www.codecademy.com/


13 votes

permalink

OK, figured this out, you have to both change "http" to "https" and even add the "/learn" ALSO, my mistake was I had "codeacademy" when it needs to be "codecademy"
hadn't realized this whole time that the site URL doesn't actually use the whole word!

// Add your code below this line!
var xhr = new XMLHttpRequest();

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

xhr.send()
// Add your code above this line!

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

896 points
Picture
Submitted by
Ryan K-Rai Stinnett
about 2 years ago

1 Comment

Picture Troy Haran almost 2 years ago

Yes, you have to use https because you are trying to make a request to an insecure URL (http) from a secure URL (https), which is not allowed in JS. Also, the /learn is not needed. It's just looking for 200 response. Request from http to https = allowed, Request from https to http = not allowed


5 votes

permalink

I found the answer guys! At least for my problem. Instead of http://www.codecademy.com I used httpS://www.codecademy.com . The added 's' solved it, in case anyone still has this problem!

626 points
38e3e8ba08c66d69ddb6c6dd3429032f?s=140&d=retro
Submitted by
mazohysta88
about 2 years ago


4 votes

permalink

Please update lesson. Must use 's' in https://www.codecademy.com

548 points
361beac67196e3a1b80345daa715cca0?s=140&d=retro
Submitted by
mark4carter
about 2 years ago

1 Comment

Cc4e584059af9027a7c15b62a970261e?s=140&d=retro hassanmtraby about 2 years ago

oh my God..yo have to use "https://www.codecademy.com" the http has to have an 's'


0 votes

permalink

me too brother, what the heck is wrong with this ?

1060 points
Cab3bcbd691e36fb59f8318e4039e085?s=140&d=retro
Submitted by
dr_sherlock
about 2 years ago


0 votes

permalink

same

735 points
Picture
Submitted by
asdcaszx
about 2 years ago


0 votes

permalink

i just posted the solution, check it out.

1060 points
Cab3bcbd691e36fb59f8318e4039e085?s=140&d=retro
Submitted by
dr_sherlock
about 2 years ago


0 votes

permalink

Thanks for posting this! I had the same problem, and adding the "s" fixed it.

465 points
23c03c30c4ff6d901b73b10eb70fb8ab?s=140&d=retro
Submitted by
oksas
about 2 years ago