Laravel Check If Api Request Code Example




Hi Guys,

In this blog,I will learn you how to check api request in can easy amd simply check to api request in laravel.

Since many applications only serve HTML or JSON, you may use the expectsJson method to quickly determine if the incoming request expects a JSON response:

if (Request::wantsJson()) {

// return JSON-formatted response

} else {

// return HTML response


It will help you....

#Laravel 8

#Laravel 7


#Laravel 6