I´m trying to call a Google Cloud Function from my Flutter App using the cloud_functions package.
This is my Cloud Function:
export const helloWorld = functions.region('europe-west1').https.onRequest((request, response) => {
response.status(200).json({
message: "Hello World!"
});
});
And this is my flutter method that calls this function:
try {
final dynamic resp =
await CloudFunctions.instance.call(
functionName: "helloWorld"
);
print(resp);
} on CloudFunctionsException catch (e) {
...
} catch (e) {
...
} finally {
...
}
As you can see it´s the most simply form of a request without any params.
My problem: Each call to the Cloud Function results in a CloudFunctionsException. Reason: "Response is not valid JSON object.".
Maybe somebody has an idea what´s going wrong here? If I call the cloud function via Postman or a browser, a valid JSON Object is returned and no exception is thrown.
Thanks in advance, Michael