Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(res => {
// 开发模式
if (isDev) {
Alert.alert(
'dev',
`${JSON.stringify(_url)} ${JSON.stringify(_config)} ${res._bodyInit}`
)
}
if (!isGet) log(method, 'success', _url, _config, res)
if (toastId) Portal.remove(toastId)
return Promise.resolve(res.text())
})
.catch(err => {
request.onreadystatechange = () => {
if (request.readyState !== 4) {
return
}
if (toastKey) {
Portal.remove(toastKey)
}
if (request.status === 200) {
success(request.responseText)
} else {
fail()
}
}
.catch(err => {
if (systemStore.state.dev) {
Alert.alert(
`${JSON.stringify(_url)} ${JSON.stringify(_config)} ${JSON.stringify(
err
)}`
)
}
if (toastKey) {
Portal.remove(toastKey)
}
return Promise.reject(err)
})
}
request.onreadystatechange = () => {
if (request.readyState !== 4) {
return
}
if (toastId) {
Portal.remove(toastId)
}
if (request.status === 200) {
success(request.responseText)
} else {
fail(request)
}
}