Laravel Check If Api Request Code Example

Admin   Laravel   115  2021-03-14 14:20:04

Hi Guys,

In this blog,I will learn you how to check api request in laravel.you 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....