Reputation: 489
I'm using JWT (Json Web Token) auth in my Laravel 5.2 app. How can I get user_id from the token inside JavaScript tags in my blade ??
Upvotes: 0
Views: 2224
Reputation: 2436
You can use JWTAuth like Auth:
After you authenticate, get the user
$user = JWTAuth::user();
then pass data to view:
return view('posts', ['user' => $user]);
and you can use the data in blade:
{{ echo $user->id; }}
Upvotes: 2