Skip to content Skip to sidebar Skip to footer

Firebase Cloud Function Returns Internal Error

I am getting the error as INTERNALwhen calling a Firebase Cloud Function from my app. Server code: exports.addToCart = functions.https.onCall((data, context) => { // Checkin

Solution 1:

You are calling your function with a String, but accessing it as a JSONObject.

The documentation for call() shows that it accepts a range of types including String, Map<String,?>, and JSONObject. That gives you some options for passing the food item and accessing it in your function.

  1. As you do now, convert the food item to a JSON string and pass the string. In the function code, you need to convert the string to an object with const food = JSON.parse(data) before accessing the fields, e.g. food.foodItem.name.

  2. If Food doesn't have many fields you could put each field in your objectHashMap and pass the map, without the conversion to JSON. Then in your function code, you could access each field without the need to use JSON.parse().

Post a Comment for "Firebase Cloud Function Returns Internal Error"