Add options to get

This commit is contained in:
danbulant 2020-02-19 19:45:38 +01:00
parent fc6617970c
commit ff990b3a95

View file

@ -3,7 +3,7 @@ const https = require("https");
/** /**
* @param {String} path * @param {String} path
*/ */
module.exports = (path) => { module.exports = (path, options = { method: "GET" }) => {
return new Promise((res, rej) => { return new Promise((res, rej) => {
if(path.startsWith("http://")){ if(path.startsWith("http://")){
var handler = http; var handler = http;
@ -13,7 +13,7 @@ module.exports = (path) => {
rej(Error("Unsupported protocol")); rej(Error("Unsupported protocol"));
} }
handler.get(path, (resp) => { handler.get(path, options, (resp) => {
let data = ''; let data = '';
resp.on('data', (chunk) => { resp.on('data', (chunk) => {