I\'m trying to learn Laravel and my goal is to be able to build a RESTful API (no use of views or blade, only JSON results. Later, an AngularJS web app and a Cordova hybrid mobi
try with this:
$user=User::where('email','=','user2@gmail.com')->first(); if (!$userToken=JWTAuth::fromUser($user)) { return response()->json(['error' => 'invalid_credentials'], 401); } return response()->json(compact('userToken'));
it works for me, hope can help