mirror of
https://github.com/qeeqbox/social-analyzer.git
synced 2026-09-28 12:34:51 +02:00
Update helper.js
This commit is contained in:
+8
-2
@@ -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: ''
|
||||
|
||||
Reference in New Issue
Block a user