Hi!!
I add dio to Flutter Web and It show this error in console:
Access to XMLHttpRequest at '
Uncaught (in promise) Error: DioError [DioErrorType.RESPONSE]: XMLHttpRequest error.
dart:sdk_internal 41685:30 get current
package:dio/src/adapters/browser_adapter.dart 75:20
dart:sdk_internal 99367:96
at Object.createErrorWithStack (dart_sdk.js:4602)
at Object._rethrow (dart_sdk.js:28602)
at async._AsyncCallbackEntry.new.callback (dart_sdk.js:28598)
at Object._microtaskLoop (dart_sdk.js:25256)
at _startMicrotaskLoop (dart_sdk.js:25262)
at dart_sdk.js:25337
But if I try get this
My
Help me!!
Nothing wrong with dio, you should add 'Access-Control-Allow-Origin' header with value 'http://127.0.0.1:8080' or '*' in your server side.
I run a server using php/laravel, all works after add below headers.
$response->header('Access-Control-Allow-Origin', $origin);
$response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Cookie, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN, Access-Control-Allow-Origin');
$response->header('Access-Control-Expose-Headers', 'Authorization, authenticated');
$response->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, OPTIONS');
$response->header('Access-Control-Allow-Credentials', 'true');
Why with 'package:http/http.dart' works correctly ?
With the same URL...
This request (http.get) works correctly:

And this request (dio.get) works wrong:

Could you see the difference?
@vico-aguado Could you give an online access url by which http package works but dio can't ?
Sure! https://www.thelotent.com/WSVistaWebClient/OData.svc/GetNowShowingSessions?$format=json&$filter=CinemaId+eq+'100'
@vico-aguado In my box, all things are right with dio.
My request codes as follows:
dio.get<String>("https://www.thelotent.com/WSVistaWebClient/OData.svc/GetNowShowingSessions?\$format=json&\$filter=CinemaId+eq+%27100%27").then((r) {
print(r.data);
}).catchError(print);

Yeah! Thank you very much! The problem was the Flutter version. This works with the new 1.10.5 (master) versi贸n. The problem was with 1.9.1 versi贸n.