鸿蒙开发使用axios请求后端网络服务出现该错误

{"message":"{"code":201,"message":"Permission denied"}","name":"AxiosError","stack":" at AxiosError (oh_modules/.ohpm/@ohos+axios@2.2.4/oh_modules/@ohos/axios/src/main/ets/components/lib/core/AxiosError.js:22:1)\n at anonymous (oh_modules/.ohpm/@ohos+axios@2.2.4/oh_modules/@ohos/axios/src/main/ets/components/lib/adapters/ohos/http.js:57:1)\n","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["ohos"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{"Blob":null},"headers":{"Accept":"application/json, text/plain, /"},"method":"get","url":"http://192.168.3.55:8080/aa"},"code":201,"status":null}

使用axios请求后端网络服务出现该错误

是没有申请网络权限

在model.json5里面添加一下网络权限就好了

bash 复制代码
"requestPermissions": [
  {
    "name": "ohos.permission.INTERNET"
  }
],
相关推荐
纯爱掌门人7 小时前
鸿蒙端云一体化开发(二):云数据库
数据库·华为·harmonyos·端云一体化
小雨青年7 小时前
【鸿蒙原生开发会议随记 Pro】 数据存储架构 RelationalStore 在复杂资产管理中的应用
华为·架构·harmonyos
时光慢煮8 小时前
基于 Flutter × OpenHarmony 的文件管家 —— 构建文件类型分类区域
flutter·华为·开源·openharmony
时光慢煮8 小时前
跨端文件管理:Flutter 与 OpenHarmony 搜索栏实战
flutter·华为·开源·openharmony
djarmy8 小时前
跨平台Flutter 开源鸿蒙开发指南(三):使用thirdParty的dio库实现网络请求 示例
flutter·华为·harmonyos
Miguo94well9 小时前
Flutter框架跨平台鸿蒙开发——护眼提醒APP的开发流程
flutter·华为·harmonyos·鸿蒙
zilikew11 小时前
Flutter框架跨平台鸿蒙开发——拼图游戏的开发流程
flutter·华为·harmonyos·鸿蒙
Easonmax12 小时前
基础入门 React Native 鸿蒙跨平台开发:帮助中心页面完整实现(常见问题+搜索+分类)
react native·react.js·harmonyos
猛扇赵四那边好嘴.12 小时前
Flutter 框架跨平台鸿蒙开发 - 手工皮具制作记录:打造专业级皮具制作管理工具
flutter·华为·harmonyos
猛扇赵四那边好嘴.12 小时前
Flutter 框架跨平台鸿蒙开发 - 免费电子书下载器:智能搜索与离线阅读
flutter·华为·harmonyos