Requests


#1

https://www.codecademy.com/ru/courses/javascript-beginner-en-EID4t/3/2?curriculum_id=5122e50456ef4d6c450008c1#

Pls help, i write this, but CA give me an error message:
image

Did you set xhr equal to new XMLHttpRequest(), then call xhr.open() with the arguments listed?

i copy block from hint, but error still exists.


#2

The course you take is no longer supported, it runs the old learning environment which is no longer supported

as such, bugs might occur and won’t get fixed.

i recommend the supported course:

https://www.codecademy.com/learn/introduction-to-javascript

but i am afraid you will have to work your way through in order to get to request section.

looking at the validation of the exercise:

try {
	xhr
} catch(ReferenceError) {
	return "Did you create a variable called xhr?";
}

if (error instanceof SyntaxError) {
  return "Your code doesn't look quite right. Check the Hint if you need help!";
}

if (!CC.printed("200")) {
  return "Did you set xhr equal to new XMLHttpRequest(), then call xhr.open() with the arguments listed? Check the Hint if you need help!";
}

if (!CC.printed("OK")) {
  return "Did you set xhr equal to new XMLHttpRequest(), then call xhr.open() with the arguments listed? Check the Hint if you need help!";
}

return true;

if (!CC.printed("200")) doesn’t seem to be working correctly, but i don’t see a way around it

well, it seems that if we define the printed method, we can trick the exercise:

// Add your code below this line!
var xhr= new XMLHttpRequest();
xhr.open("GET", "https://www.codecademy.com",false);
xhr.send()

// Add your code above this line!

CC = {}
CC.printed = function(){
    return true;
}

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

REST API with Javascript
Oops, try again. Did you console.log(xhr.statusText)?
Error in sending request to API
Bug: Problem with Making Requests
#3

If the tutorial is obsolete, kindly take it down.

Simples.


#4

It will be taken down, finding this tutorial takes effort. Its not featured on the main site, its difficult to find.


#5