uni-app 真机运行及云端打包后 接口请求报"errMsg": "request:fail abort statusCode:-1"
uni-app 真机运行及云端打包后 接口请求报"errMsg": “request:fail abort statusCode:-1”
| 类别 | 信息 |
|---|---|
| 产品分类 | uniapp/App |
| PC开发环境 | Windows |
| PC版本号 | win10 |
| HBuilderX | 正式 |
| HBuilderX版本 | 3.1.13 |
| 手机系统 | iOS |
| 手机版本 | IOS 14 |
| 手机厂商 | 苹果 |
| 手机机型 | iphone11 |
| 页面类型 | vue |
| 打包方式 | 云端 |
| 项目创建方式 | HBuilderX |
示例代码:
uni.request({
url: `${config.base.loginIP}/connect/token`, //仅为示例,并非真实接口地址。
data: {
client_id: 'HKERP2.0',
client_secret: 'ClientKey',
grant_type: 'password',
isApp: true,
...formData
},
sslVerify: false,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
},
success: (res) =>{
uni.hideLoading();
uni.showToast({
title: error+error_description,
icon: 'none'
});
let {
access_token,
expires_in,
error_description,
error
} = res.data;
uni.setStorageSync('userCode', _this.requireParams.username)
uni.setStorageSync('TOKEN_FRESHTIME', expires_in);
uni.setStorageSync('aliToken', 'Bearer ' + access_token);
if (error) {
uni.showToast({
title: error_description,
icon: 'none'
});
} else {
_this.getUserInfo(flag);
}
},
fail:(res)=>{
uni.hideLoading();
console.info(res)
}
});
操作步骤:
- 真机调试、打包后接口请求异常
预期结果:
- 能正常访问接口
实际结果:
- “errMsg”: “request:fail abort statusCode:-1”
bug描述:
- uni-app真机调试以及云端打包后,uni.request 请求"errMsg": “request:fail abort statusCode:-1”,但运行至浏览器端接口能正常访问
更多关于uni-app 真机运行及云端打包后 接口请求报"errMsg": "request:fail abort statusCode:-1"的实战教程也可以访问 https://www.itying.com/category-93-b0.html
1 回复


