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

How to use APIs with JavaScript Forum

View Course

115 points
504a1b4459e1f100020749da_684531800
Submitted by
Jairo Romero
over 4 years ago

Why do I get ¨oops, try it again. Did you console.log(xhr.status)?

I had the following request for this section and got the unexpected result. Why???

My code:
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);


7 votes

permalink

Hi!
The syntax for console is actually console.log(something) and not console.log=(something).
I hope it helps!

2058 points
99c7cbbb63819a75320edb5191f46bcf?s=140&d=retro
Submitted by
Marcio Chertman
over 4 years ago

1 Comment

6756c9a7797cbf7affe79126da187df0?s=140&d=retro mckinsey2 over 4 years ago

true


2 votes

permalink

If you're still having issues, change the url to https://...

508 points
C94b3f2739d95710ad436ad68682575b?s=140&d=retro
Submitted by
David Gibbs
almost 2 years ago


0 votes

permalink

Don't know if you solved this in the end, but I believe all you need to do is remove your "=" signs actually, since we're not setting a value for 'console.log' but rather asking console to log something by checking a variable (using the parantheses versus the equals)

28 points
Af8ae5bb6b7bf4a88afa1b36654c0e02?s=140&d=retro
Submitted by
Ashwin Anandani
over 3 years ago


0 votes

permalink

I have this as the code and I still get an error:

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);

Oops, try again. Did you console.log(xhr.status)?
TypeError: Property 'log' of object # is not a function


Please help what am I doing wrong?

274 points
Picture
Submitted by
CsKgamers
over 3 years ago

1 Comment

5382ff7052f863954b006e6f_777979731 Zhouhancheng about 3 years ago

your codes works


0 votes

permalink

Seems to be a bug with state.
had the same problem.
logging out and logging in again and continue the course should work

588 points
C17f8d9cdca6f0fc575dfcaec34bc02d?s=140&d=retro
Submitted by
knecht
almost 3 years ago


-1 votes

permalink

I wrote the syntax correcty but still got an error. I solved it by changing the second parameter of the .open() method to point to a non-existing location

207 points
5220b373548c351a35003205_952802627
Submitted by
Daniel Plop
over 3 years ago