diff options
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | server/js/apibay.js | 16 | ||||
-rw-r--r-- | views/result.ejs | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/package.json b/package.json index fa9361a..f2c7c36 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "author": "Rafael Marçalo", "license": "GPL-3.0-or-later", "dependencies": { - "axios": "^1.1.3", "ejs": "^3.1.8", "express": "^4.18.2" }, 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}; diff --git a/views/result.ejs b/views/result.ejs index b4ba849..47ecdee 100644 --- a/views/result.ejs +++ b/views/result.ejs @@ -17,7 +17,7 @@ </tr> </thead> <tbody class="table-group-divider"> - <% results.data.forEach(result => { %> + <% results.forEach(result => { %> <tr> <td class="text-start text-white limit-text"><%= result.name %></td> <td class="text-white"><%= functions.getCategory(parseInt(result.category)) %></td> |