Calling a Cloud Function from an iOS app looks like this:
var functions = Functions.functions() functions.httpsCallable(name).call(data){ (result, error) in // Code here } How can I send an error from my Cloud Function, so it will get picked up in the above code? For example:
Cloud Function:
exports.joinGame = functions.https.onCall((data, context) => { return Error("The game is full") }) SwiftUI:
var functions = Functions.functions() functions.httpsCallable("joinGame").call(data){ (result, error) in print(error) // "The game is full" }
HTTPSCallableResult?,Error?) in SwiftUI - I want to return an error message from my cloud function that will appear under the 2nd parameter of the response (Error). @Asperi{ error: "error message" }or{ success: "success message" }depending on the scenario. Thanks.{ "success": true/false, "message":null/"Game full" }or whatever