修改网络请求

master
夜笙歌 2 years ago
parent 1cc5b8c6b8
commit 4293840522

@ -4,17 +4,21 @@ async function autoUpdate(url, interval, callback = () => {}, method = 'post') {
type: method, type: method,
url: url, url: url,
dataType: 'json', dataType: 'json',
timeout:9000,
success: function (data) { success: function (data) {
setTimeout(() => autoUpdate(url, interval, callback, method), interval)
callback(data) callback(data)
resolve(data) resolve(data)
}, },
error: function (reason) { error: function (reason) {
setTimeout(() => autoUpdate(url, interval, callback, method), interval)
console.error(reason) console.error(reason)
reject(reason) reject(reason)
} }
}) })
}) })
setTimeout(() => autoUpdate(url, interval, callback, method), interval)
} }
const INTERVAL = 10000 const INTERVAL = 10000

Loading…
Cancel
Save