Skip to content

Corrected spelling and punctuation #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions example/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ void main() async {
/// Do not forget to call [Client.close] when you're done using it.
final httpClient = Client();

/// We'll use a logging handler to how the requests and responses
/// We'll use a logging handler to show the requests and responses.
final httpHandler = LoggingHttpHandler(DartHttp(httpClient),
onRequest: (r) => print('${r.method} ${r.uri}'),
onResponse: (r) => print('${r.statusCode}'));

/// The JSON:API client
final client = RoutingClient(JsonApiClient(httpHandler), routing);

/// Create the first resource
/// Create the first resource.
await client.createResource(
Resource('writers', '1', attributes: {'name': 'Martin Fowler'}));

/// Create the second resource
/// Create the second resource.
await client.createResource(Resource('books', '2', attributes: {
'title': 'Refactoring'
}, toMany: {
'authors': [Identifier('writers', '1')]
}));

/// Fetch the book, including its authors
/// Fetch the book, including its authors.
final response = await client.fetchResource('books', '2',
parameters: Include(['authors']));

/// Extract the primary resource
/// Extract the primary resource.
final book = response.data.unwrap();

/// Extract the included resource
/// Extract the included resource.
final author = response.data.included.first.unwrap();

print('Book: $book');
Expand Down