problem with HTTP requests in the code playground | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

problem with HTTP requests in the code playground

I'm trying to use the API from another site in a program in the code playground. The XMLHttpRequest only reaches a readyState of 1, meaning a server connection was established, but doesn't go any further. Is this specific to SoloLearn or am I most likely just making a mistake?

27th Sep 2017, 5:30 AM
Ashley Niemerg
Ashley Niemerg - avatar
5 Answers
+ 9
i assume the problematic code is the one in your codes list? here's a modified version https://code.sololearn.com/WqQw5Q8RnqFk/?ref=app
27th Sep 2017, 6:07 AM
Burey
Burey - avatar
+ 10
wasn't CORS (well it was actually, but dealt with it with the cors-anywhere API) main problem was not creating a listener to handle the response here's some stuff to read @Ashley XMLHttpRequest MDN: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest cors-anywhere: https://github.com/Rob--W/cors-anywhere/blob/master/README.md end point for making requests https://cors-anywhere.herokuapp.com/<your requested url>
27th Sep 2017, 6:19 AM
Burey
Burey - avatar
+ 2
Maybe CORS protection. Could you share your code here?
27th Sep 2017, 6:01 AM
Calviղ
Calviղ - avatar
+ 2
yep, it's the one in my code list. Thanks @Burey!
27th Sep 2017, 12:33 PM
Ashley Niemerg
Ashley Niemerg - avatar
0
nice code:)
25th Feb 2018, 9:42 PM
saschacode