trevorwang / retrofit.dart

retrofit.dart is an dio client generator using source_gen and inspired by Chopper and Retrofit.
https://mings.in/retrofit.dart/
MIT License
1.07k stars 246 forks source link

XMLHttpRequest error in WEB #605

Open john-smith-rk opened 1 year ago

john-smith-rk commented 1 year ago

DioError [DioErrorType.response]: XMLHttpRequest error.

I got above error in Chrome for WEB. How should i solve it?

trevorwang commented 11 months ago

Would you please provide more information here?

yanmastra commented 8 months ago

I got the same error

this is the error detail

POST http://localhost:20001/api/v1/auth/authenticate_json
Accept: application/json
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: *
Access-Control-Allow-Headers: *
{"username":"weoidhoihed","password":"23oeihoi23heio2","app_code":"xxxxxxx"}
2

Error connectionError, http://localhost:20001/api/v1/auth/authenticate_json, msg: 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.
error response:
error dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 941:28              get current
packages/dio/src/options.dart 335:56                                            compose
packages/my_admin/data/repository/public_repository.g.dart 34:20        authenticate
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54              runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5              _async
packages/my_admin/data/repository/public_repository.g.dart 24:34        authenticate
packages/my_admin/features/auth/controller/login_controller.dart 36:52  signIn
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50              <fn>
dart-sdk/lib/async/zone.dart 1661:54                                            runUnary
dart-sdk/lib/async/future_impl.dart 162:18                                      handleValue
dart-sdk/lib/async/future_impl.dart 846:44                                      handleValueCallback
dart-sdk/lib/async/future_impl.dart 875:13                                      _propagateToListeners
dart-sdk/lib/async/future_impl.dart 638:7                                       [_complete]
dart-sdk/lib/async/future.dart 424:15                                           <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 48:11         internalCallback

and this is my Rest Client

part 'public_repository.g.dart';

@RestApi(baseUrl: "https://api.myhost.com")
abstract class PublicRepository {
  factory PublicRepository(Dio dio, {String baseUrl}) = _PublicRepository;

  @POST("api/v1/auth/authenticate_json")
  Future<ApiRespose> authenticate(@Body() Credential credential);
}