From 27220a7877d5751eee9104e091e14fc1991ff431 Mon Sep 17 00:00:00 2001 From: fan-droide Date: Wed, 7 Dec 2022 15:34:17 +0100 Subject: [PATCH] fix http requests as node module --- freesound.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/freesound.js b/freesound.js index dc0b934..a9ecce3 100644 --- a/freesound.js +++ b/freesound.js @@ -58,15 +58,14 @@ } if (typeof module !== 'undefined'){ // node.js - var http = require("http"); + var https = require("https"); var options = { host: host, path: uri.substring(uri.indexOf("/",8),uri.length), // first '/' after 'http://' - port: '80', method: method, headers: {'Authorization': authHeader} }; - var req = http.request(options,function(res){ + var req = https.request(options,function(res){ var result = ''; res.setEncoding('utf8'); res.on('data', function (data){ @@ -74,7 +73,7 @@ }); res.on('end', function() { if([200,201,202].indexOf(res.statusCode)>=0) - success(wrapper?wrapper(data):data); + success(wrapper?wrapper(result):result); else error(data); });