简体   繁体   English

颤振:DioError [DioErrorType.response]:XMLHttpRequest 错误

[英]flutter: DioError [DioErrorType.response]: XMLHttpRequest error

I created an app and test it on emulator and andriod phone, i am using api's and nodejs based backend and mongodb database.我创建了一个应用程序并在模拟器和安卓手机上对其进行了测试,我正在使用基于 api 和 nodejs 的后端和 mongodb 数据库。 it works fine when i test it on devices, but when i run it on chrome it sends me this error.当我在设备上测试它时它工作正常,但是当我在 chrome 上运行它时它向我发送这个错误。

Error:错误:

Error: Unsupported operation: NetworkInterface.list

DioError [DioErrorType.response]: XMLHttpRequest error.

here is my dio request code这是我的 dio 请求代码

Code:代码:

calltimeInApi() async {
    Dio dio=new Dio();
    var data={
      'username': getname,
      'token': getaccesstoken,
      
    };
    timeOutButtonPressed=true;
    await dio
    .post(localhostUrlTimeIn,data: json.encode(data))
      .then((onResponse)async {
       
        getapitimein=onResponse.data['TimeIn'];


      }).catchError((onerror){
        print(onerror.toString());
    });
  }

please help where i am doing wrong!请帮助我做错了什么!

There doesn't seem to be any issues on the code snippet that you've shared.您共享的代码段似乎没有任何问题。 If the HTTP Requests works fine on mobile devices but not on web, I suggest check the logs if you're getting CORS errors.如果 HTTP 请求在移动设备上运行良好但在网络上运行良好,我建议您在遇到 CORS 错误时检查日志。 A quick workaround on this issue is by running the web app with html renderer in debug.解决此问题的一个快速解决方法是在调试中运行带有 html 渲染器的 Web 应用程序。

flutter run -d chrome --web-renderer html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter DioError [DioErrorType.response]:XMLHttpRequest 错误 - Flutter DioError [DioErrorType.response]: XMLHttpRequest error Flutter:DioError [DioErrorType.RESPONSE]:Http 状态错误 [500] - Flutter: DioError [DioErrorType.RESPONSE]: Http status error [500] Flutter DioError [DioErrorType.RESPONSE]: Http 状态错误 [403] - Flutter DioError [DioErrorType.RESPONSE]: Http status error [403] Flutter Dio:DioError [DioErrorType.RESPONSE]:Http 状态错误 [429] - Flutter Dio : DioError [DioErrorType.RESPONSE]: Http status error [429] DioError [DioErrorType.response] Http 状态错误 [404] - flutter - DioError [DioErrorType.response] Http status error [404] - flutter I/flutter (28276):此处发现错误 DioError [DioErrorType.response]:Http 状态错误 [404] - I/flutter (28276): Error found Here DioError [DioErrorType.response]: Http status error [404] I/flutter (23942): DioError [DioErrorType.RESPONSE]: Http 状态错误 [500] - I/flutter (23942): DioError [DioErrorType.RESPONSE]: Http status error [500] flutter 未处理的异常:DioError [DioErrorType.response]:Http 状态错误 [422] - flutter Unhandled Exception: DioError [DioErrorType.response]: Http status error [422] DioError [DioErrorType.RESPONSE]: Http 状态错误 [400] 异常 - DioError [DioErrorType.RESPONSE]: Http status error [400] Exception DioError [DioErrorType.RESPONSE]:Http 状态错误 [500],为什么? - DioError [DioErrorType.RESPONSE]: Http status error [500], why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM