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

How to use APIs with JavaScript Forum

View Course

434 points
Ccd352f7cdca2113bc42978ec32c29d8?s=140&d=retro
Submitted by
shreyasm123
almost 2 years ago

Whats wrong with my answer 5/19

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


20 votes

permalink

Add an 's' after 'http' in your codecademy URL.

607 points
2a18b0d1b7d172b3161aab533e38991c?s=140&d=retro
Submitted by
u0481014
almost 2 years ago

8 Comments

55b0c6c9d3292fe1a200042e_597700130 Gabriel Checchia Vitali almost 2 years ago

Thank you! It worked for me!

557cf6db9113cb0ef6000060_726972838 thebrightobvious almost 2 years ago

Exercise 1 already has "http" written in, not "https". Clicking "submit" results in passing the level but doesn't print "200" or "OK" to the console. Seems like an error in the instructions.

55b44964e39efe2b2b0000cf_208709394 Taylor Palmer almost 2 years ago

Had the same problem. That's pretty dumb.

20f07c51b1b53277eba315b8e3ad0360?s=140&d=retro batraaf almost 2 years ago

Thanks, this solved it!

84d2a778ceda00652dffacf5ec1a20b3?s=140&d=retro Natalie Harzic almost 2 years ago

That really helped. It definitely should be fixed as the hint text suggests that an error was made in typing the required code and not that some existing code is already wrong. Thanks for the help.

Picture Mark Gould almost 2 years ago

Any reason why there is an s included here?

522b8c0df10c60ae650034d2_394003798 Daniel Lobo almost 2 years ago

Same here. Thanks it worked.

Picture AshTube almost 2 years ago

Mark, it's because the site now loads over a HTTPS connection, but the tutorial was written when it loaded over http, so the URL being requested for the API is incorrect, and the code therefore doesn't work.


-2 votes

permalink

When you open developer console, there is a reason:
Mixed Content: The page at 'https://www.codecademy.com/assets/repl.html' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.codecademy.com/'. This request has been blocked; the content must be served over HTTPS.

HTTPS, hypertext transfer protocol secure, is HTTP through a secured connection. If you want to know more about it, check this article:https://www.godaddy.com/help/http-vs-https-5454

854 points
Picture
Submitted by
Sarah Kwak
almost 2 years ago