Skip to content

Commit 8a031db

Browse files
authored
Remove example use of missing Response.bodyFields (#597)
Closes #173 I don't think it is common for a server to respond with `form-data` formatted data. Instead use a more realistic example of the server responding with JSON.
1 parent f93c76f commit 8a031db

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ If you do this, make sure to close the client when you're done:
3030
```dart
3131
var client = http.Client();
3232
try {
33-
var uriResponse = await client.post(Uri.parse('https://example.com/whatsit/create'),
33+
var response = await client.post(
34+
Uri.https('example.com', 'whatsit/create'),
3435
body: {'name': 'doodle', 'color': 'blue'});
35-
print(await client.get(uriResponse.bodyFields['uri']));
36+
var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)) as Map;
37+
var uri = Uri.parse(decodedResponse['uri'] as String);
38+
print(await client.get(uri));
3639
} finally {
3740
client.close();
3841
}

0 commit comments

Comments
 (0)