mirror of https://github.com/jak0099/dr.git
17 lines
485 B
JavaScript
17 lines
485 B
JavaScript
let req = (url, options) => http(url, Object.assign({
|
|
async: false
|
|
}, options));
|
|
|
|
function http(url, options = {}) {
|
|
if (options?.async === false) return _http(url, options)
|
|
return new Promise(resolve => _http(url, Object.assign({
|
|
complete: res => resolve(res)
|
|
}, options))).catch(err => {
|
|
console.error(err.name, err.message, err.stack)
|
|
return {
|
|
ok: false,
|
|
status: 500,
|
|
url
|
|
}
|
|
})
|
|
} |