Skip to content

Commit 6adaa03

Browse files
chalinnex3
authored andcommitted
README: fix broken links and BrowserClient example (#38)
- Updated links from api.dartlang.org to dartdocs.org. - BrowserClient was missing. - BrowserClient example: wrapped bare code in `main` function.
1 parent e6d0ccc commit 6adaa03

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

README.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,17 @@ You can also exert more fine-grained control over your requests and responses by
4444
creating [Request][] or [StreamedRequest][] objects yourself and passing them to
4545
[Client.send][].
4646

47-
[Request]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/http/http.Request
48-
49-
[StreamedRequest]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/http/http.StreamedRequest
50-
51-
[Client.send]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/http/http.Client#id_send
47+
[Request]: https://www.dartdocs.org/documentation/http/latest/http/Request-class.html
48+
[StreamedRequest]: https://www.dartdocs.org/documentation/http/latest/http/StreamedRequest-class.html
49+
[Client.send]: https://www.dartdocs.org/documentation/http/latest/http/Client/send.html
5250

5351
This package is designed to be composable. This makes it easy for external
5452
libraries to work with one another to add behavior to it. Libraries wishing to
5553
add behavior should create a subclass of [BaseClient][] that wraps another
5654
[Client][] and adds the desired behavior:
5755

58-
[BaseClient]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/http/http.BaseClient
59-
60-
[Client]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/http/http.Client
56+
[BaseClient]: https://www.dartdocs.org/documentation/http/latest/http/BaseClient-class.html
57+
[Client]: https://www.dartdocs.org/documentation/http/latest/http/Client-class.html
6158

6259
```dart
6360
class UserAgentClient extends http.BaseClient {
@@ -79,17 +76,20 @@ The HTTP library can be used on the browser via the [BrowserClient][] class in
7976
`package:http/browser_client.dart`. This client translates requests into
8077
XMLHttpRequests. For example:
8178

79+
[BrowserClient]: https://www.dartdocs.org/documentation/http/latest/http.browser_client/BrowserClient-class.html
80+
8281
```dart
82+
import 'dart:async';
8383
import 'package:http/browser_client.dart';
84-
import 'package:http/http.dart' as http;
8584
86-
var client = new BrowserClient();
87-
var url = "/whatsit/create";
88-
client.post(url, body: {"name": "doodle", "color": "blue"})
89-
.then((response) {
90-
print("Response status: ${response.statusCode}");
91-
print("Response body: ${response.body}");
92-
});
85+
main() async {
86+
var client = new BrowserClient();
87+
var url = '/whatsit/create';
88+
var response =
89+
await client.post(url, body: {'name': 'doodle', 'color': 'blue'});
90+
print('Response status: ${response.statusCode}');
91+
print('Response body: ${response.body}');
92+
}
9393
```
9494

9595
## Filing issues

0 commit comments

Comments
 (0)