daniel19
daniel19

Reputation: 77

Why do I get an error message in Laravel, but the request is still running?

I am currently working on a project where I am currently building the rest API. I'm making the backend part of the project in Laravel. I was just about to tokenize what I was doing with Sanctum when I saw an error in my code. I get an error on this line:

auth()->user()->tokens()->delete();

For some reason, the VS Code editor throws an error at the tokens () function, but the biggest surprise for me is that the request runs successfully. Maybe someone has any idea what the problem might be?

Here is the full logout() function:

public function logout()
{
    auth()->user()->tokens()->delete();
    return [
        "message" => "Logged out!"
    ];
}

EDIT: The error message: Undefined method 'tokens'.intelephense(1013)

Upvotes: 0

Views: 1169

Answers (1)

Abdusalam mohamed
Abdusalam mohamed

Reputation: 378

The problem is not with vs it is in intelephense not being able to locate the Tokens annotation try

    $request->user()->tokens()->delete();

make sure your route has the Auth:sanctum middleware on

Upvotes: 3

Related Questions