Skip to content

Commit 6c5a887

Browse files
authored
Fix code example in README (#51)
1 parent 66e812b commit 6c5a887

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8-
## [2.0.0]
8+
9+
## [2.0.1] - 2019-07-12
10+
### Fixed
11+
- Readme example is outdated
12+
13+
## [2.0.0] - 2019-07-12
914

1015
### Changed
1116
- This package now consolidates the Client, the Server and the Document in one single library.
@@ -76,7 +81,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7681
### Added
7782
- Client: fetch resources, collections, related resources and relationships
7883

79-
[Unreleased]: https://github.com/f3ath/json-api-dart/compare/1.0.1...HEAD
84+
[Unreleased]: https://github.com/f3ath/json-api-dart/compare/2.0.1...HEAD
85+
[2.0.1]: https://github.com/f3ath/json-api-dart/compare/2.0.0...2.0.1
86+
[2.0.0]: https://github.com/f3ath/json-api-dart/compare/1.0.1...2.0.0
8087
[1.0.1]: https://github.com/f3ath/json-api-dart/compare/1.0.0...1.0.1
8188
[1.0.0]: https://github.com/f3ath/json-api-dart/compare/0.6.0...1.0.0
8289
[0.6.0]: https://github.com/f3ath/json-api-dart/compare/0.5.0...0.6.0

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
# Client
44
Quick usage example:
55
```dart
6+
import 'package:http/http.dart';
67
import 'package:json_api/json_api.dart';
78
89
void main() async {
9-
final client = JsonApiClient();
10+
final httpClient = Client();
11+
final jsonApiClient = JsonApiClient(httpClient);
1012
final companiesUri = Uri.parse('http://localhost:8080/companies');
11-
final response = await client.fetchCollection(companiesUri);
12-
13+
final response = await jsonApiClient.fetchCollection(companiesUri);
14+
httpClient.close();
1315
print('Status: ${response.status}');
14-
print('The collection page size is ${response.data.collection.length}');
16+
print('Headers: ${response.headers}');
1517
16-
final resource = response.data.collection.first.toResource();
17-
print('The first element is ${resource}');
18+
final resource = response.data.unwrap().first;
1819
20+
print('The collection page size is ${response.data.collection.length}');
21+
print('The first element is ${resource}');
1922
print('Attributes:');
2023
resource.attributes.forEach((k, v) => print('$k=$v'));
21-
2224
print('Relationships:');
2325
resource.toOne.forEach((k, v) => print('$k=$v'));
2426
resource.toMany.forEach((k, v) => print('$k=$v'));

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ author: "Alexey Karapetov <karapetov@gmail.com>"
22
description: "JSON:API Client for Flutter, Web and VM. Supports JSON:API v1.0 (http://jsonapi.org)"
33
homepage: "https://github.com/f3ath/json-api-dart"
44
name: "json_api"
5-
version: "2.0.0"
5+
version: "2.0.1"
66
dependencies:
77
collection: "^1.14.11"
88
http: "^0.12.0"

0 commit comments

Comments
 (0)