Reputation: 1059
I met an error when I am using Dio. Below is my code:
var response = await Dio().post("http://test.worldstreet.cn/service/account/verificationCode/send", data: { "phoneRegion": _phoneRegion, "phoneNumber": _phoneNumber, "action": "$_action" });
Below is the error:
[+1036 ms] Error: DioException [connection error]: The connection errored: The XMLHttpRequest onError callback was called. This typically indicates an error on the network layer. This indicates an error which most likely cannot be solved by the library.
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3 throw_
packages/dio/src/dio_mixin.dart 509:7 fetch
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 60:31 <fn>
dart-sdk/lib/async/zone.dart 1666:54 runBinary
dart-sdk/lib/async/future_impl.dart 177:22 handleError
dart-sdk/lib/async/future_impl.dart 850:46 handleError
dart-sdk/lib/async/future_impl.dart 871:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 651:5 [_completeError]
dart-sdk/lib/async/future_impl.dart 737:7 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7 <fn>
I can't find any references online. I am pretty sure the backend api is 100% ok. I have tried flutter clean
.
Please help!
Upvotes: 3
Views: 8186
Reputation: 66
This error is likely caused by CORS policy. You can disable it when debugging application in Chrome using disable-web-security command as described here:
How to solve flutter web api cors error only with dart code?
Upvotes: 5