isoos / http_client

https://pub.dartlang.org/packages/http_client
BSD 3-Clause "New" or "Revised" License
13 stars 6 forks source link

Error: Not found: 'dart:html' #2

Closed crazecoder closed 5 years ago

crazecoder commented 5 years ago
import 'package:http_client/browser.dart' as http;

void main(){
  http.Client client = http.BrowserClient();
  client.send(http.Request('GET', "http://https://github.com")).then((_response){
    print(_response.body);
  });
}
isoos commented 5 years ago

@crazecoder: are you running it in a console (e.g. dart main.dart)? In that case you should import http_client/console.dart.

isoos commented 5 years ago

another thing, I'd suggest using the following, because it is simpler:

Future main() async {
  final client = new http.ConsoleClient();
  final rs = await client.send(http.Request('GET', "http://https://github.com"));
  print(rs.body);
}