-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix code snippets in rest api section
- Loading branch information
1 parent
e271b64
commit ecf201e
Showing
6 changed files
with
29 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 4 additions & 9 deletions
13
src/fragments/lib-v1/restapi/flutter/getting-started/40_postTodo.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
```dart | ||
import 'dart:typed_data'; | ||
Future<void> postTodo() async { | ||
try { | ||
final options = RestOptions( | ||
path: '/todo', | ||
body: Uint8List.fromList('{\'name\':\'Mow the lawn\'}'.codeUnits) | ||
); | ||
final restOperation = Amplify.API.post( | ||
restOptions: options | ||
'todo', | ||
body: HttpPayload.json({'name': 'Mow the lawn'}), | ||
); | ||
final response = await restOperation.response; | ||
print('POST call succeeded'); | ||
print(response.body); | ||
print(response.decodeBody()); | ||
} on ApiException catch (e) { | ||
print('POST call failed: $e'); | ||
} | ||
} | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters