Created
December 22, 2022 15:41
-
-
Save omarzer0/90b5ca46944e6dc20d0d2b04daf32ac5 to your computer and use it in GitHub Desktop.
async await
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
import 'dart:convert'; | |
import 'package:http/http.dart' as http; | |
void main() async { | |
// Uri uri1 = Uri.parse('https://example.com/whatsit/create'); | |
// http.get(uri1).then((value) => print(value.statusCode)); | |
// Uri uri2 = Uri.parse('https://jsonplaceholder.typicode.com/albums/1'); | |
// http.get(uri2).then((value) => print(value.statusCode)); | |
// for(int i = 0; i <= 9 ; i++){ | |
// for(int j = 0; j <= 9 ; j++){ | |
// Uri uri = Uri.parse('https://files.fm/u/7z${i}62qe${j}u'); | |
// http.get(uri).then((value){ | |
// if(value.statusCode == 200){ | |
// print('https://files.fm/u/7z${i}62qe${j}u'); | |
// } | |
// }); | |
// } | |
// } | |
request1(); | |
} | |
void request1() async { | |
Uri url = Uri.parse("https://jsonplaceholder.typicode.com/users/1"); | |
var response = await http.get(url); | |
var result = json.decode(response.body); | |
print(result['email']); | |
print(result['username']); | |
print(result['address']['street']); | |
print(result['address']['geo']['lat']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment