summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Marçalo <raroma09@gmail.com>2022-10-22 19:14:40 +0100
committerRafael Marçalo <raroma09@gmail.com>2022-10-22 19:14:40 +0100
commit4f26ab9c157fe3c395f7e452120a97bc8cb8d8d8 (patch)
tree38bf4176c9de00be4c8be7941ad807f542b6d36d
parent00c740712c3b56aba08416d386529f0104628c45 (diff)
Replaced axios with stock nodejs https library
-rw-r--r--package.json1
-rw-r--r--server/js/apibay.js16
-rw-r--r--views/result.ejs2
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>