title: IN Flutter Web getting 'XMLHttpRequest' error while making HTTP call
body: <p>I am using XAMPP control panel and using a local server like Apache port no 80, but in flutter web getting XMLHttpRequest error and in mobile device. The same coding fetches data using API not getting any error.
  How to fetch data using API while app run on flutter-web?</p>
  <p>Error</p>
  <pre><code>Launching lib\main.dart on Chrome in debug mode...
  Syncing files to device Chrome...
  Debug service listening on ws://127.0.0.1:56619/FsXy3a4ZrZg=
  Debug service listening on ws://127.0.0.1:56619/FsXy3a4ZrZg=
  Error: XMLHttpRequest error.
      C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28                get current
  packages/http/src/browser_client.dart 84:22                                                                                    &lt;fn&gt;
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1450:54                                              runUnary
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 143:18                                        handleValue
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 696:44                                        handleValueCallback
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 725:32                                        _propagateToListeners
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 519:7                                         [_complete]
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_pipe.dart 61:11                                         _cancelAndValue
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream.dart 1302:7                                             &lt;fn&gt;
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14  _checkAndCall
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39  dcall
  C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/html/dart2js/html_dart2js.dart 37312:58                              &lt;fn&gt;
      
      at Object.createErrorWithStack (http://localhost:5555/dart_sdk.js:4361:12)
      at Object._rethrow (http://localhost:5555/dart_sdk.js:38189:16)
      at async._AsyncCallbackEntry.new.callback (http://localhost:5555/dart_sdk.js:38183:13)
      at Object._microtaskLoop (http://localhost:5555/dart_sdk.js:38015:13)
      at _startMicrotaskLoop (http://localhost:5555/dart_sdk.js:38021:13)
      at http://localhost:5555/dart_sdk.js:33518:9
  </code></pre>
  <p>Backend Side PHP Webservice</p>
  <pre><code>&lt;?php
  
  header(&quot;Access-Control_Allow_Origin: *&quot;);
  header(&quot;Access-Control-Allow-Credentials: true&quot;);
  header(&quot;Content-type:application/json;charset=utf-8&quot;); 
  header(&quot;Access-Control-Allow-Methods: GET&quot;);
  
  include 'config.php';
  
  $sql=&quot;select * from calinsert&quot;;
  $result=mysqli_query($conn,$sql)or die(&quot;query failed&quot;);
  
  if(mysqli_num_rows($result) &gt;0){
      $output=mysqli_fetch_all($result,MYSQLI_ASSOC);
      echo json_encode($output);
  }
  else{   
      echo json_encode(array('message'=&gt;'no record found','status'=&gt;false));
  }
  ?&gt;
  </code></pre>
  <p>Flutter Side Code</p>
  <pre><code>Future getdata()async {
      final response = await http.get(
          'http://localhost:80/web_service/calview.php',
          headers: {
            &quot;Accept&quot;: &quot;application/json&quot;,
            &quot;Access-Control_Allow_Origin&quot;: &quot;*&quot;
          });
  
      print(response.statusCode);
      print(response.body);
    }
  </code></pre>