postman中没有填数据报这个500错误
我把namespace use JWTAuth 换成了 use Tymon\JWTAuth\JWTAuth还是不行
"message": "Non-static method Tymon\\JWTAuth\\JWTAuth::attempt() should not be called statically",
"status_code": 500,
"debug": {
"line": 26,
"file": "/home/vagrant/Code/learn-api/app/Api/Controllers/AuthController.php",
"class": "ErrorException",
"trace": [
"#0 /home/vagrant/Code/learn-api/app/Api/Controllers/AuthController.php(26): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8192, 'Non-static meth...', '/home/vagrant/C...', 26, Array)",
25行
namespace App\Api\Controllers;
//use JWTAuth;
use Tymon\JWTAuth\JWTAuth;
use Illuminate\Http\Request;
use Tymon\JWTAuth\Exceptions\JWTException;
class AuthController extends BaseController
{
public function authenticate(Request $request)
{
// grab credentials from the request
$credentials = $request->only('email', 'password');
try {
// attempt to verify the credentials and create a token for the user
if (! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
// something went wrong whilst attempting to encode the token
return response()->json(['error' => 'could_not_create_token'], 500);
}
// all good so return the token
return response()->json(compact('token'));
}
}