@@ -19,29 +19,36 @@ class GridProxyClient {
1919 Future <dynamic > getRequest (
2020 String path, Map <String , dynamic >? queryParameters) async {
2121 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+ });
2430
2531 final uri = Uri .parse (baseUrl);
2632 final scheme = uri.scheme;
2733 final host = uri.host;
2834
29- final requestUri = convertedQueryParameters != null &&
30- convertedQueryParameters.isNotEmpty
35+ final requestUri = encodedQueryParams.isNotEmpty
3136 ? (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 ))
3439 : (scheme == 'https' ? Uri .https (host, path) : Uri .http (host, path));
40+
3541 final response = await http.get (requestUri);
3642
3743 if (response.statusCode == 200 ) {
3844 final jsonData = json.decode (response.body);
3945 return jsonData;
4046 } 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 }' );
4249 }
4350 } catch (e) {
44- throw Exception ('Error: $e ' );
51+ throw Exception ('Error during GET request to $ path : $e ' );
4552 }
4653 }
4754}
0 commit comments