Flutter web app http request with package http: ^0.13.3. below is my code to retrieves data from api Server.
var data = await http.get(Uri.http(ServerRoot, "api/conversation/1"),);
But adding authentication header gives me following error. this same code working well on android and iOS project, but web project gives me error.
var data = await http.get(Uri.http(ServerRoot, "api/conversation/1"),
headers: {
HttpHeaders.authorizationHeader: "bearer $token"
});
I am unable to retrieve data and it gives me following error
Error: XMLHttpRequest error.
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 909:28 get current
packages/http/src/browser_client.dart 71:22 <fn>
dart-sdk/lib/async/zone.dart 1613:54 runUnary
dart-sdk/lib/async/future_impl.dart 155:18 handleValue
dart-sdk/lib/async/future_impl.dart 707:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 736:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 533:7 [_complete]
dart-sdk/lib/async/stream_pipe.dart 61:11 _cancelAndValue
dart-sdk/lib/async/stream.dart 1219:7 <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39 dcall
dart-sdk/lib/html/dart2js/html_dart2js.dart 37307:58 <fn>
at Object.createErrorWithStack (http://localhost:49464/dart_sdk.js:5054:12)
at Object._rethrow (http://localhost:49464/dart_sdk.js:37670:16)
at async._AsyncCallbackEntry.new.callback (http://localhost:49464/dart_sdk.js:37666:13)
at Object._microtaskLoop (http://localhost:49464/dart_sdk.js:37526:13)
at _startMicrotaskLoop (http://localhost:49464/dart_sdk.js:37532:13)
at http://localhost:49464/dart_sdk.js:33303:9