How to handle custom error in rest.php file
Closed this issue · 1 comments
ankitpatelinitio commented
Hello,
I passed auth token from react application to suite CRM and I have to check whether this token is expired or not in the rest.php file and on that basis I have to return custom message. So how can I return a custom error message and handle in my application.
Thanks.
mrbarletta commented
If you are going to use api v8 tokens then rest.php will not work, it only works using cookies (logged in users).
If you want something else, then you need to extend Slim framework adding a middleware and inspecting the request.
All you have to do is create the graphql/CustomRest.php
file and there you can add something like
$app->add(function ($req, $res, $next) {
//Add your own middleware logic here
$response = $next($req, $res);
return $response;
});