Laravel memeriksa apakah permintaan API

if (Request::wantsJson()) {
    // return JSON-formatted response
} else {
    // return HTML response
}
Cybernated Dev