diff options
Diffstat (limited to 'server/js/apibay.js')
-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}; |