I'm trying to access a callable function's error message within an Angular environment using the angular fire package. Please see the following code:
Angular (Client-Side)
async myCallableFunction(id: string) {
try {
const res = await this.afFunctions.httpsCallable('callableFunction')({
id
}).toPromise();
console.log(res);
} catch (err) {
console.error('Error is:', err);
}
}
Server Side (Firebase Function)
exports.callableFunction = functions.https.onCall((data: {
id: string
}, context: https.CallableContext) => {
// throw error for testing only
throw new https.HttpsError('unknown', 'Test Error Message');
});
And the error message logged to the console is:
[console.error]: "Error is:" { "code": "unknown", "line": 100205, "column": 32, "sourceURL": "http://192.168.1.100:8100/vendor.js" }
How do I access the error message from the response by Cloud Firestore?
Thanks in advance.