diff options
author | Rafael Marçalo <raroma09@gmail.com> | 2022-10-22 19:14:40 +0100 |
---|---|---|
committer | Rafael Marçalo <raroma09@gmail.com> | 2022-10-22 19:14:40 +0100 |
commit | 4f26ab9c157fe3c395f7e452120a97bc8cb8d8d8 (patch) | |
tree | 38bf4176c9de00be4c8be7941ad807f542b6d36d /server | |
parent | 00c740712c3b56aba08416d386529f0104628c45 (diff) |
Replaced axios with stock nodejs https library
Diffstat (limited to 'server')
-rw-r--r-- | server/js/apibay.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/server/js/apibay.js b/server/js/apibay.js index e141259..9ef7326 100644 --- a/server/js/apibay.js +++ b/server/js/apibay.js @@ -1,16 +1,26 @@ "use strict"; -const axios = require('axios'); +const https = require('https'); + const server = 'https://apibay.org'; async function getRequest(url) { - return await axios.get(url); + let promise = new Promise( resolve => { + let data = ''; + + https.get(url, res => { + res.on('data', chunk => {data += chunk}); + res.on('end', () => resolve(data)); + }); + }); + + return await promise; } async function hit(query) { - return await getRequest(server + '/q.php?q=' + encodeURI(query)); + return JSON.parse(await getRequest(server + '/q.php?q=' + encodeURI(query))); } module.exports = {hit}; |