Skip to content
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

XMLHttpRequest error in get request (web ) #3080

Open
bennajah opened this issue Apr 16, 2024 · 1 comment
Open

XMLHttpRequest error in get request (web ) #3080

bennajah opened this issue Apr 16, 2024 · 1 comment
Assignees

Comments

@bennajah
Copy link

ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR BUGS DESCRIPTION.
Fill in the template. Issues that do not respect the model will be closed.

Describe the bug
when use GetConnect for http request getting this error Error: XMLHttpRequest error. only in Web app (Mobile is working)
tested in http & dio client and works good this issue only in GetConnect in Web app

Reproduction code
NOTE: THIS IS MANDATORY, IF YOUR ISSUE DOES NOT CONTAIN IT, IT WILL BE CLOSED PRELIMINARY)

example:

import 'package:get/get.dart';

class UserProvider extends GetConnect {
  @override
  void onInit() {
    httpClient.baseUrl = 'http://line.protv.cc';
  }

  Future<void> getUser() async {
    try {
      final response = await get(
        '/player_api.php',
        query: {
          "username": "47f393c353",
          "password": "ab8f02caa435",
        },
      );
      if (response.status.hasError) {
        print('Error: ${response.statusText}');
      } else {
        print('Response: ${response.bodyString}');
      }
    } catch (e) {
      print(e);
    }
  }
}

To Reproduce
Steps to reproduce the behavior:
lunch app in web
then try to make this api request using GetConnect

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
Http & Dio packages return 200 response status
but GetConnect return error
image

Flutter Version:
3.19.5

Getx Version:
4.6.6

Describe on which device you found the bug:
Web (Chrome)

Minimal reproduce code
Provide a minimum reproduction code for the problem

@bennajah
Copy link
Author

Api Request working in Web using fetchClient with cors Mode

import 'package:fetch_client/fetch_client.dart';
import 'package:http/http.dart';

Client httpClient() => FetchClient(mode: RequestMode.cors);

but not working using GetConnect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants