Is there any way to use an IP address instead of a domain name in node.js Request module?
I am getting the following error: [Error: Invalid URI "192.168.0.101/relay1/on"]
I know I shouldn't include the url scheme (e.g: http), so http:// 192.168.0.101/relay1/on wouldn't work either.
Below is the code generating the error:
var arduinoRequestURL = arduinoIp + '/' + modulePrivateName + '/' + req.params.action;
request(arduinoRequestURL, function (error, response, body) {
console.log(body);
console.log(error);
console.log(response);
});
And here is a link to the module: https://github.com/mikeal/request
Yes, you can. Also you must specify the protocol for request.
request('google.com', function (error, response, body) {
console.log(body);
console.log(error);
console.log(response);
});
gives [Error: Invalid URI "google.com"]
The following are equivalent:
request('http://google.com', function (error, response, body) {
console.log(body);
console.log(error);
console.log(response);
});
request('http://74.125.236.18', function (error, response, body) {
console.log(body);
console.log(error);
console.log(response);
});