Reputation: 414
I am using Firebase JWT in one of my SLIM framework apps for RESTFul api. But all the JWT errors occur as slim app error rather than throwing back json errors ,which i can return to user. Like in image below
Can you help how can i display JWT errros in json format ,so that my restful api return that json error to user.
Upvotes: 0
Views: 194
Reputation: 5262
If you need to output error as JSON, you need to handle the exception. For example:
try {
//do something when everything is OK
} catch (\Firebase\JWT\SignatureInvalidException $e) {
return $response->withJson(
(object) [
'error' => true,
'code' => $e->getCode(),
'message' => $e->getMessage()
],
500
);
}
Upvotes: 1