2
votes

I am trying to make an http post request using the Dio package on flutter Web with the code below but whenever click the button to make the request I get the error in the picture with no data returned.I dont get what may be causing the problem.

Map<String,dynamic> postData = {
  "email":"[email protected]",
  "password":"qwerty123456",
};

var resp = await dio.post("http://10.15.5.46/codeishweb/LoginUser.php",data: postData );
   if (resp.statusCode == 200) { 
      if(resp.data != null){
        print("not null");
       responseBody = resp.data;
       print("results ::$responseBody");
      }else{
        print("The request gave null");
      }

Dio Error

1
Hi, if you can add the error log here, it would be great. Also, I couldn't help but noticing that the baseUrl is an empty String. Issue must be somewhat related to that - Harshvardhan Joshi
I'm facing the same error. Same code working in android but in web req.body.name receive undefined value. - Abdullah Khan
@AbdullahKhan did you find a solution for your issue? I have the sam problem. Works on Android but not web - DrkStr
@DrkStr I didn't remember clearly but i think i did this using http plugin. pub.dev/packages/http - Abdullah Khan
I am facing the same issue, have you found any solution? - Rashesh Bosamiya

1 Answers

-1
votes

I think because of 'http', your URL should be 'https'