@@ -15,33 +15,33 @@ void main() async {
15
15
/// Do not forget to call [Client.close] when you're done using it.
16
16
final httpClient = Client ();
17
17
18
- /// We'll use a logging handler to how the requests and responses
18
+ /// We'll use a logging handler to show the requests and responses.
19
19
final httpHandler = LoggingHttpHandler (DartHttp (httpClient),
20
20
onRequest: (r) => print ('${r .method } ${r .uri }' ),
21
21
onResponse: (r) => print ('${r .statusCode }' ));
22
22
23
23
/// The JSON:API client
24
24
final client = RoutingClient (JsonApiClient (httpHandler), routing);
25
25
26
- /// Create the first resource
26
+ /// Create the first resource.
27
27
await client.createResource (
28
28
Resource ('writers' , '1' , attributes: {'name' : 'Martin Fowler' }));
29
29
30
- /// Create the second resource
30
+ /// Create the second resource.
31
31
await client.createResource (Resource ('books' , '2' , attributes: {
32
32
'title' : 'Refactoring'
33
33
}, toMany: {
34
34
'authors' : [Identifier ('writers' , '1' )]
35
35
}));
36
36
37
- /// Fetch the book, including its authors
37
+ /// Fetch the book, including its authors.
38
38
final response = await client.fetchResource ('books' , '2' ,
39
39
parameters: Include (['authors' ]));
40
40
41
- /// Extract the primary resource
41
+ /// Extract the primary resource.
42
42
final book = response.data.unwrap ();
43
43
44
- /// Extract the included resource
44
+ /// Extract the included resource.
45
45
final author = response.data.included.first.unwrap ();
46
46
47
47
print ('Book: $book ' );
0 commit comments