kh_dev1's avatar

Access Nested Object

how i can get token from this? it get from JSON code in below {success: {…}} success: token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzIiwianRpIjoiMTU3ZDI4MmRhMDg1ZGQ0NmNjM2Q2ZWMwYWFmOTQ0ZWFjNDYxM2U0ZDEyMzk0NTQ1OGJhOTQ0MzdhYzFlNjRmZmVjY2RlMzEzMmI3ODdmNmMiLCJI" proto: Object proto: Object

0 likes
2 replies
Tray2's avatar

What is the exact json structure of the response?

1 like
kh_dev1's avatar

i'm using Laravel Passport whenever i'm login it will be return like that

public function login(){ if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){ $user = Auth::user(); $success['token'] = $user->createToken('crm')-> accessToken; return response()->json(['success' => $success], $this-> successStatus); } else{ return response()->json(['error'=>'Unauthorised'], 401); } }

Please or to participate in this conversation.