SPA using Laravel 5.8 / Vue - auth() returns token true instead of token value SPA using Laravel 5.8 / Vue - auth() returns token true instead of token value vue.js vue.js

SPA using Laravel 5.8 / Vue - auth() returns token true instead of token value


You should use the JWTAuth facade provided by the package:

        if (! $token = \JWTAuth::attempt($credentials)) {            return Response::json(['error' => 'Unauthorized'], 401);        }


you can use guard('api') or guard('users') method, since you have multiple guards

    $credentials = request(['email', 'password']);    if (!$token = auth()->guard('api')->attempt($credentials)) {         return response()->json(['error' => 'Unauthorized'], 401);    }        return $token;