I am trying to use firebase auth to verify a token.
In the reference for this method, it is written:
Returns:
Promise
A promise fulfilled with the token's decoded claims if the ID token is valid; otherwise, a rejected promise.
In MDN concerning promisses it is written:
If the Promise is rejected, the await expression throws the rejected value.
Therefore, how do I know if the value I got is from the promisse being reject or being fulfilled?
My code:
try {
const decoded = await adminAuth.verifyIdToken(idToken);
const uid = decoded.uid;
/*...*/
return next();
} catch (err) {
return res.status(500).json({ err });
}
I get that probably the value of decoded for a rejected promisse won't have a uid field thus throwing an error, but how can I be sure of that?