-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: DioError [connection error]: The connection errored: The XMLHttpRequest onError callback was called. This typically indicates an error on the network layer. #1664
Comments
CORS can't be fixed on the client side. Please make sure that your request is correct, i.e. all headers are correct, the correct HTTP method is used and that the url is correct. As of right now, the issue is not actionable. I'm going to close the issue because of that and your indication that it might be CORS. Feel free to reopen the issue, if you still think it's a dio issue. |
I was on the same error. |
I am having same issue. How to fix it i have dio interceptor where i tried to add cors headers as well. @OverRide can you share your code snippets |
Is this code at your client or server ?? |
This video tutorial below worked for me. After that it is important to clean, run these commands: |
dio.options.headers['Demo-Header'] = after remove this line code |
Hi, i am having the same issue but I am using a third party API "HitHorizon". I have not control over the backend development. The API works fine on my flutter android and also tested on Postman. The only issue is with Flutter web. |
Hi , the backend api send responses with content type "application/json;" and the dio in flutter can't read the response maybe in the network debug tool the response is fine `Future ping() async {
}` and this is the error
flutter doctor -v `[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [version 10.0.22621.3447], locale en-ZA) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.33) [!] Android Studio (not installed) [√] VS Code (version 1.83.1) [√] Connected device (4 available) [√] Network resources ! Doctor found issues in 1 category.` this is the response details in flutter devtool network tab |
Package
dio
Version
5.0.0
Output of
flutter doctor -v
Dart Version
2.19.0
Steps to Reproduce
when I try to call twitter api when using flutter for web with this code
final dioObject = dio.Dio();
await dioObject.post("https://api.twitter.com/oauth/request_token");
I see people talk about enabling CORS but I use twitter api so I haven't access to server side how I can solve this ?
Expected Result
response with token
Actual Result
Error: DioError [connection error]: The connection errored: The XMLHttpRequest onError callback was called. This typically indicates an error on the network layer.
dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw
packages/dio/src/dio_mixin.dart 530:7
dart-sdk/lib/async/zone.dart 1665:54 runBinary
dart-sdk/lib/async/future_impl.dart 162:22 handleError
dart-sdk/lib/async/future_impl.dart 779:46 handleError
dart-sdk/lib/async/future_impl.dart 800:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 575:5 [_completeError]
dart-sdk/lib/async/future_impl.dart 51:12 [_completeError]
dart-sdk/lib/async/future_impl.dart 23:5 completeError
dart-sdk/lib/async/future.dart 617:44 onError
dart-sdk/lib/async/zone.dart 1665:54 runBinary
dart-sdk/lib/async/future_impl.dart 162:22 handleError
dart-sdk/lib/async/future_impl.dart 779:46 handleError
dart-sdk/lib/async/future_impl.dart 800:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 575:5 [_completeError]
dart-sdk/lib/async/future_impl.dart 666: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 166:15
The text was updated successfully, but these errors were encountered: