Why does my http GET request always return an error?


#1

I am currently developing a Cloud9 plugin, where I need to make a GET
request to a remote web server. The following code is what I use to
perform the request:

var http = imports.http;
http.request(url, {}, function(err, data, res) {
if(err) {
alert(err);
}
}

When I perform the same GET request in a web browser, valid JSON is
returned. However, using this code, I always receive an EventProgress object,
which tells me that the number of loaded bytes is 0. What is going
wrong?


#2

Maybe that site doesn’t allow cross origin requests.
What is the url?


#3

The url points to a java servlet running on a jetty server on the same host as cloud9 at the moment. So i probably need to set the access-control-allow-origin header?


#4

Yes this seems to work