I am trying to implement dingo API with laravel 5.2
Following is a function which I have written for testing dingo
public function profile()
{
try {
$user = JWTAuth::parseToken()->toUser();
if (!$user) {
return response()->json(['error' => 'User Not Found'], 500);
}
} catch (\Tymon\JWTAuth\Exceptions\JWTException $ex) {
return response()->json(['error' => 'Something went wrong'], 500);
}
//return response()->json(['user' => $user->with('profile')->where('id', $user->id)->first()], 200);
return $this->response->array($user->toArray());
}
It works fine when I use
return response()->json(['user' => $user], 200);
But when I use following line of code in accordance with dingo syntax. It shows error
return $this->response->array($user->toArray());
Basically none of the dingo defined functions work. How can this be resolved?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire