I am developing on Ionic Framework 2.0.0-beta.4
. My node version is v4.4.7
.
I am trying to use NodeJS http.
My code:
var http = require('http');
var options = {
host: 'www.google.com',
port: 80,
path: '/index.html',
};
http.get(options, function(res) {
console.log("Got response: " + res.statusCode);
res.on("data", function(chunk) {
console.log("BODY: " + chunk);
});
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
The error i am getting is:
Fetch API cannot load http://www.google.com/index.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access.
Got error: Failed to fetch
I have tried searching online but the solutions are not working for me. Does anybody have a suggestion?
EDIT : I am running Node.Js on an Android application.