0
votes

I am trying to fetch data from a web API , I am using this method for fetching :

Future<dynamic> AfficherEtablissement() async {
   final response =
   await http.get('https://jsonplaceholder.typicode.com/albums/1');
   if (response.statusCode == 200) {
     var parsedJson = json.decode(response.body);
     print(parsedJson) ;
     //decode
     List<dynamic> data = json.decode(response.body);
     return data  ;
   } else {
     throw Exception('Failed to load');
   }
 } 

I am getting this error :

'_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<dynamic, String>

in this line :

List<dynamic> data = json.decode(response.body);
1

1 Answers

0
votes

Use

Map<String, dynamic> data = json.decode(response.body);

instead of

List<dynamic> data = json.decode(response.body);