我想问为什么接口在 500
之后依然会进行跳转呢?难道不是 catch
然后弹窗报错了么?
const Api_Common = async (Path: string, Function: string, Params: any = {}) => await axios
.post(`host`, Params)
.then((data: Response) => data.data.Response)
.catch((e) => {
return ErrorState.dispatch(Publish(e.response.data.Error))
})
const Api_Account_Register = (mobile: string, password: string, captcha: string) => Api_Common( Path, "account_register", {
mobile: mobile,
password: password,
captcha: captcha
})
Api_Account_Register( mobile, password, code )
.then(() => messageApi.success('注册成功').then(() => navigate('/首页')))
Api_Common
确实catch
了,但是catch
没有继续把错误抛出,catch
返回了一个新的promise
,也就继续执行Api_Account_Register
后面的then
了MDN - Promise.catch