HarmonyOS axios接口请求

axios请求接口,已经添加了参数,但是服务端收不到参数,参数的格式和加密已经调过了确认无问题。

运行报错如下:

{"code":10001,"msg":"phone is required"}
  • 1.

代码如下:

import axios, { AxiosError, AxiosResponse } from '@ohos/axios';
import RequestResult from '../http/ResponseResult';

let callBackData: RequestResult = new RequestResult();
return axios<InfoModel, AxiosResponse<InfoModel>, InfoModel>({
  method: http.RequestMethod.POST,
  url: 'http://huawei.com',
  data: {
    n1: '100021',
    n2: '10073',
    n3: '3',
    n4: 'xxx',
    n5: 'c2ec2fc2-c358-49b3-a636-65a3b68b0903',
    n6: 'com.xxx',
    n7: 'c2ec2fc2-c358-49b3-a636-65a3b68b0903',
    encData: '{"aesKey":"KTNiY1bgsjKJOKdkf+EykNjFYTMIbwuiO9k/YAh5gKF4x1uvHKxcFYmZDTCujGJKYzV007FUQTmhsm0z/HwOSv0UJb4wN3RABDjUKSc3xA5Nz5C+ZNQ7DQA2VKaZET6RfZ52EhZAJmD6hhLl69BYpduzIGDgLyg7GjS1ATsy5TA=","data":"9elNUOxN3BGsBsqHFSkJ5cd+jBy/Tvhlq/QFWJ2VhUQ="}',
    device: 'c2ec2fc2-c358-49b3-a636-65a3b68b0903',
    phone: 'xxx',
    sign: 'Juq2NTX/uifkGFP/E8MLzanwHRbuidEUIOUHaKQ25iVbktLtP8zg/wSzwGt0rNNb5QlPCZ9uWieJ5NfHTIpfmLOIgVr4K+BMiJIbQSpVFPMHKadirn0huEVuViuLvhteua+UTD+IfhkIqxxHw47wdq2fqWc2l6/ffwjlc7FlMSQ=',
    timestamp: '1721012627700'
  }
}).then((res: AxiosResponse) => {
  console.log("tag", '【http请求工具】 code=' + res.status + ' data=' + JSON.stringify(res.data));
  return callBackData;
}).catch((error: AxiosError) => {
  console.error("tag", '请求失败  ' + error.message);
  return callBackData;
})
  • 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.
HarmonyOS
2024-12-25 08:08:03
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

需要设置:

headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  • 1.
分享
微博
QQ
微信
回复
2024-12-25 11:37:56
相关问题
HarmonyOS 接口请求处理
1068浏览 • 1回复 待解决
HarmonyOS 接口请求处理处理
847浏览 • 1回复 待解决
HarmonyOS 网络接口请求查看功能
689浏览 • 1回复 待解决
鸿蒙JS开发 接口请求loading??
7257浏览 • 1回复 已解决
鸿蒙JS开发 接口请求loading?
6467浏览 • 1回复 待解决
HarmonyOS 接口请求数据处理
698浏览 • 1回复 待解决
HarmonyOS 如何发起网络接口请求
753浏览 • 1回复 待解决
HarmonyOS 有没有接口请求时loading组件
613浏览 • 1回复 待解决
鸿蒙JS开发 蓠接口请求loading?
4514浏览 • 1回复 待解决
HarmonyOS axios请求问题
809浏览 • 1回复 待解决
HarmonyOS 如何处理axios请求
871浏览 • 1回复 待解决
HarmonyOS http使用axios库的接口缓存
903浏览 • 1回复 待解决
基于@ohos/axios的网络请求能力
1385浏览 • 1回复 待解决