Back to APIs list
US Congress Stock Trading API examples & templates
Use these vals as a playground to view and fork US Congress Stock Trading API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
safeAssertBearerToken
@neverstew
Script
safeAssertBearerToken A safe version of assertBearerToken that handles errors and presents them as a property on the returned object instead. Example const handler = (req, res) => {
const authorization = req.get('authorization');
const { error, data: token } = @neverstew.safeAssertBearerToken(@me.secrets.superSecret, authorization);
if (error) {
res.status(401).send("Unauthorized");
return;
}
res.json(token);
}