Hi,
Im trying to use GraphQL using Flutter. But I keep on getting "Unable to unserialize value." error. I've been googling for this for hours and still get not getting the expected result.
My code below:
Future<void> fetchPost() async {
final String url =
'http://m23ee-mag2-demo.datasolution-aspac.site/graphql';
final String requestBody = """
{
products(search: "shirt") {
items {
sku
name
description {
html
}
small_image {
url
}
}
}
}
""";
Map<String, String> requestHeaders = {
'Content-type': 'application/json'
};
final response =
await http.post(url, headers: requestHeaders, body: requestBody);
if (response.statusCode == 200) {
print(json.decode(response.body));
} else {
// If that response was not OK, throw an error.
//throw Exception('Failed to load post');
print(response.body);
}
}