check request is from api in laravel code example
Example: laravel check if api request
if (Request::wantsJson()) {
// return JSON-formatted response
} else {
// return HTML response
}
if (Request::wantsJson()) {
// return JSON-formatted response
} else {
// return HTML response
}