mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 15:36:07 +00:00 
			
		
		
		
	
		
			
	
	
		
			20 lines
		
	
	
	
		
			483 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
		
		
			
		
	
	
			20 lines
		
	
	
	
		
			483 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
|   | import 'dart:convert'; | ||
|  | 
 | ||
|  | import 'package:http/http.dart' as http; | ||
|  | 
 | ||
|  | class MyWebApi { | ||
|  |   final _baseUrl = "dummy.test.org"; | ||
|  | 
 | ||
|  |   Future<MyResponse> fetchData( | ||
|  |       String id) async { | ||
|  |     String apiPath = "/my_path/" + id; | ||
|  |     final response = await http.get(Uri.https(_baseUrl, apiPath)); | ||
|  |     if (response.statusCode == 200) { | ||
|  |       print(response.body); | ||
|  |       return MyResponse.fromJson(json.decode(response.body)); | ||
|  |     } else { | ||
|  |       throw Exception('Failed to load data'); | ||
|  |     } | ||
|  |   } | ||
|  | } |