0

Trying to logout a logged in user using postman in laravel sanctum.

But error appearing like below:

Argument 1 passed to Illuminate\\Routing\\RouteFileRegistrar::{closure}() must be an instance of Illuminate\\Http\\Request, instance of Illuminate\\Routing\\Router given, called in E:\\Projects\\crowdFunding\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php on line 423"

Things I have done:

  1. included accept:application/json in postman

  2. included bearer token

  3. My logout code in controller:

    
    return response()->json([
        'message' => 'logged out'
    ]);
    

But not working.

1 Answer 1

1

You may update logout method as below in your controller.

public function logout(Request $request)
{
    $request->user()->tokens()->delete();
    return response()->json([
        'message' => 'logged out'
    ]);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.