鸿蒙开发使用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"
  }
],
相关推荐
Georgewu1 小时前
【HarmonyOS 6】 The target can not be empty. check the build.profile,json5 file of
harmonyos
Georgewu2 小时前
【HarmonyOS 6】Install Failed: error: failed to install bundle.code:9568322
harmonyos
爱笑的眼睛113 小时前
HarmonyOS 应用开发新范式:深入剖析 Stage 模型与 ArkTS 状态管理
华为·harmonyos
爱笑的眼睛115 小时前
深入浅出 HarmonyOS ArkUI 3.0:基于声明式开发范式与高级状态管理构建高性能应用
华为·harmonyos
电手6 小时前
时隔4年麒麟重新登场!华为这8.8英寸新「手机」给我看麻了
华为·智能手机
程序员潘Sir8 小时前
鸿蒙应用开发从入门到实战(一):鸿蒙应用开发概述
harmonyos
敲代码的鱼哇11 小时前
跳转原生系统设置插件 支持安卓/iOS/鸿蒙UTS组件
android·ios·harmonyos
在下历飞雨12 小时前
Kuikly基础之状态管理与数据绑定:让“孤寡”计数器动起来
ios·harmonyos
在下历飞雨12 小时前
Kuikly基础之Kuikly DSL基础组件实战:构建青蛙主界面
ios·harmonyos
HarmonyOS小助手13 小时前
HEIF:更高质量、更小体积,开启 HarmonyOS 图像新体验
harmonyos·鸿蒙·鸿蒙生态