its been about three days and I couldn't solve this issue I have looked everywhere (the documentations, stackoverflow ...etc) but with no luck.

Anyway my problem is that whenever I send a POST request to the login api `localhost:8000/api/auth/login` I always get this error : 

```
{
"error": "Unauthorized"
}

```

and here is my request body :

```
{
"email": "demo@demo.demo",
"password": "123321"
}

```

I have followed the official documentations : <https://jwt-auth.readthedocs.io/en/develop/quick-start/>

**Edit 1**

request header (postman) :

`Content-Type: application/json`

Routes : 

```
Route::group([

'middleware' => 'api',
'prefix' => 'auth'

], function ($router) {

Route::post('login', 'AuthController@login');
Route::post('logout', 'AuthController@logout');
Route::post('refresh', 'AuthController@refresh');
Route::post('me', 'AuthController@me');

});

```

`login` function located in `app/Http/Controllers/AuthController.php` :

```
 public function login()
{
    $credentials = request(['email', 'password']);

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

    return $this->respondWithToken($token);
}

```

**Edit 2**
here is the route list : 

```
|        | GET|HEAD | /                |      | Closure                                     | web          |
|        | POST     | api/auth/login   |      | App\Http\Controllers\AuthController@login   | api          |
|        | POST     | api/auth/logout  |      | App\Http\Controllers\AuthController@logout  | api,auth:api |
|        | POST     | api/auth/me      |      | App\Http\Controllers\AuthController@me      | api,auth:api |
|        | POST     | api/auth/refresh |      | App\Http\Controllers\AuthController@refresh | api,auth:api |

```

**Edit 3**

```
protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }

```