@@ -19,29 +19,36 @@ class GridProxyClient {
19
19
Future <dynamic > getRequest (
20
20
String path, Map <String , dynamic >? queryParameters) async {
21
21
try {
22
- final convertedQueryParameters = queryParameters
23
- ? .map ((key, value) => MapEntry (key, value? .toString () ?? '' ));
22
+ final Map <String , String > encodedQueryParams = {};
23
+ queryParameters? .forEach ((key, value) {
24
+ if (value is List ) {
25
+ encodedQueryParams[key] = value.map ((e) => e.toString ()).join (',' );
26
+ } else if (value != null ) {
27
+ encodedQueryParams[key] = value.toString ();
28
+ }
29
+ });
24
30
25
31
final uri = Uri .parse (baseUrl);
26
32
final scheme = uri.scheme;
27
33
final host = uri.host;
28
34
29
- final requestUri = convertedQueryParameters != null &&
30
- convertedQueryParameters.isNotEmpty
35
+ final requestUri = encodedQueryParams.isNotEmpty
31
36
? (scheme == 'https'
32
- ? Uri .https (host, path, convertedQueryParameters )
33
- : Uri .http (host, path, convertedQueryParameters ))
37
+ ? Uri .https (host, path, encodedQueryParams )
38
+ : Uri .http (host, path, encodedQueryParams ))
34
39
: (scheme == 'https' ? Uri .https (host, path) : Uri .http (host, path));
40
+
35
41
final response = await http.get (requestUri);
36
42
37
43
if (response.statusCode == 200 ) {
38
44
final jsonData = json.decode (response.body);
39
45
return jsonData;
40
46
} else {
41
- throw Exception ('Failed to load data got: ${response .body }' );
47
+ throw Exception (
48
+ 'Failed to load data. Status: ${response .statusCode }, Body: ${response .body }' );
42
49
}
43
50
} catch (e) {
44
- throw Exception ('Error: $e ' );
51
+ throw Exception ('Error during GET request to $ path : $e ' );
45
52
}
46
53
}
47
54
}
0 commit comments