Update helper.js

This commit is contained in:
Giga
2022-05-12 13:06:34 -07:00
committed by GitHub
parent 01d7cba0ed
commit 2c84f93309
+8 -2
View File
@@ -186,7 +186,7 @@ function get_site_from_url (_url) {
return temp.replace('nothinghere.', '')
}
async function get_url_wrapper_json (url, time = 5) {
async function get_url_wrapper_json (url, time = 2) {
try {
const http_promise = new Promise((resolve, reject) => {
const request = https.get(url, header_options, function (res) {
@@ -219,7 +219,7 @@ async function get_url_wrapper_json (url, time = 5) {
}
}
async function get_url_wrapper_text (url, time = 5) {
async function get_url_wrapper_text (url, time = 2) {
const response_body = 'error-get-url'
try {
const http_promise = new Promise((resolve, reject) => {
@@ -232,6 +232,12 @@ async function get_url_wrapper_text (url, time = 5) {
resolve(body)
})
})
const timeout = (time !== 0) ? time * 1000 : 5000
request.setTimeout(timeout, function() {
reject({
data: ''
})
});
request.on('error', function (e) {
reject({
data: ''