鸿蒙js报{“code”:200,“data”:“request data error”}
1.确认后端的json数据没有问题
2.配置config.json
在module中添加internet权限
{
"app": {
"vendor": "example",
"bundleName": "cyou.guadou.movie",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {
"default": {
"network": {
"cleartextTraffic": true
}
}
},
"module": {
"reqPermissions": [{
"name": "ohos.permission.INTERNET",
"reason": "网络http请求"
}
],
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "js",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"formsEnabled": false,
"label": "$string:MainAbility_label",
"type": "page",
"launchType": "standard"
},
{
"name": ".DataDefault",
"srcLanguage": "js",
"srcPath": "DataDefault",
"icon": "$media:icon",
"description": "$string:DataDefault_desc",
"type": "data",
"uri": "dataability://cyou.guadou.movie.DataDefault"
}
],
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "cyou.guadou.movie",
"name": ".entry",
"js": [
{
"pages": [
"pages/index/index",
"pages/default/default"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"name": "cyou.guadou.movie.DataAbilityShellProvider.PROVIDER"
}
]
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.
- 81.
- 82.
- 83.
- 84.
- 85.
- 86.
- 87.
- 88.
- 89.
4.仍然报错
5.发现用的是https网络,所以去除network的"cleartextTraffic": true字段,发现可以正常请求了
没有用