解决:未设置 custom.catch: true,会返回一个永远 pending 的 Promise
This commit is contained in:
parent
37f9b0b6e8
commit
9c7b0a2373
|
|
@ -106,7 +106,8 @@ export const applyTaskDelay = (payload) => {
|
|||
export const createTask = (payload) => {
|
||||
return uni.$uv.http.post('/bst/task', payload, {
|
||||
custom: {
|
||||
auth: true
|
||||
auth: true,
|
||||
catch: true // 允许在 catch 中处理错误
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -862,7 +862,8 @@ const handleSubmit = async () => {
|
|||
});
|
||||
|
||||
try {
|
||||
await createTask(payload);
|
||||
const res = await createTask(payload);
|
||||
console.log('@@@@@@@@@@',res);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '创建成功',
|
||||
|
|
@ -874,14 +875,11 @@ const handleSubmit = async () => {
|
|||
}, 1200);
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
submitting.value = false;
|
||||
console.error('创建任务失败:', error);
|
||||
uni.showToast({
|
||||
title: error.message || '创建失败,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
// 错误提示已在响应拦截器中统一处理,这里不需要重复显示
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
console.log('submitting', submitting.value);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export const Request = () => {
|
|||
// 初始化请求配置
|
||||
uni.$uv.http.setConfig((config) => {
|
||||
/* config 为默认全局配置*/
|
||||
config.baseURL = 'http://192.168.1.5:4001'; /* 根域名 */
|
||||
config.baseURL = 'http://192.168.1.9:4001'; /* 根域名 */
|
||||
// config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */
|
||||
return config
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user