HTTP Request from inside WASM in Dart using package:web

This example uses packages/web and directly invokes fetch().

See the output in browser developer console.

Actual code:


import 'package:web/web.dart' as web;

final resp =
  await web.window.fetch('https://httpbin.org/anything'.toJS).toDart;
final txt = await resp.text().toDart;
print('body: ${txt}');

Info