Skip to content
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

Pass a URI to package:http API #5202

Merged
merged 2 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/docs/cookbook/networking/fetch-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This recipe covers how to fetch a sample album from the
<!-- skip -->
```dart
Future<http.Response> fetchAlbum() {
return http.get('https://jsonplaceholder.typicode.com/albums/1');
return http.get(Uri.https('jsonplaceholder.typicode.com','albums/1'));
}
```

Expand Down Expand Up @@ -242,7 +242,7 @@ import 'package:http/http.dart' as http;

Future<Album> fetchAlbum() async {
final response =
await http.get('https://jsonplaceholder.typicode.com/albums/1');
await http.get(Uri.https('jsonplaceholder.typicode.com', 'albums/1');

if (response.statusCode == 200) {
// If the server did return a 200 OK response,
Expand Down
10 changes: 5 additions & 5 deletions src/docs/cookbook/networking/send-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ by sending an album title to the
```dart
Future<http.Response> createAlbum(String title) {
return http.post(
'https://jsonplaceholder.typicode.com/albums',
Uri.https('jsonplaceholder.typicode.com','albums'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
Expand Down Expand Up @@ -132,8 +132,8 @@ function to return a `Future<Album>`:
<!-- skip -->
```dart
Future<Album> createAlbum(String title) async {
final http.Response response = await http.post(
'https://jsonplaceholder.typicode.com/albums',
final response = await http.post(
Uri.https('jsonplaceholder.typicode.com','albums'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
Expand Down Expand Up @@ -242,8 +242,8 @@ import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

Future<Album> createAlbum(String title) async {
final http.Response response = await http.post(
'https://jsonplaceholder.typicode.com/albums',
final response = await http.post(
Uri.https('jsonplaceholder.typicode.com','albums'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
Expand Down