Native (HTTPS)
Installing & Making a Request
Since HTTPS is a module in the standard library for Node.js, there's no need to install an external dependancy to make a request with HTTPS. Simply create a new instance of the module and format the request.
var qs = require("querystring");
var http = require("https");
var options = {
"method": "{{HTTP_METHOD}}",
"hostname": "{{API_URL}}",
"path": "{{API_PATH}}",
"headers": {
"x-rapidapi-key": "{{API_KEY}}",
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(qs.stringify({}));
req.end();
Updated over 5 years ago