HarmonyOS 模拟器抓包问题?

ohos.request (上传下载) 能力如何调试

我使用的是模拟器,配置了抓包工具Charles,普通请求都能抓包获取;

开发图片上传功能过程中:

let uploadTask: request.UploadTask;
let uploadConfig: request.UploadConfig = {
  url: 'http://www.huawei.com', // 需要手动将 url 替换为真实服务器的 HTTP 协议地址
  header: { 'Accept': '*/*' },
  method: "POST",
  files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }],
  data: [{ name: "name123", value: "123" }],
};
try {
  request.uploadFile(getContext(), uploadConfig).then((data: request.UploadTask) => {
    uploadTask = data;
  }).catch((err: BusinessError) => {
    console.error(`Failed to request the upload. Code: ${err.code}, message: ${err.message}`);
  });
} catch (err) {
  console.error(`Failed to request the upload. err: ${JSON.stringify(err)}`);
}

抓包工具没有抓到对应的链接,这个是在模拟器上无法调试,还是配置错误,为什么触发不了请求;

断点调试

uploadTask.on('complete', upCompleteCallback);
uploadTask.on('progress', upProgressCallback);
阅读 430
logo
HarmonyOS
子站问答
访问
宣传栏