Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Griehle's avatar

Why does this work?

I saw this syntax in forgot password and its so nice. I tried it on my own but it doesnt work. So. How is it that this post route works? What am I missing here? Thank you in advance.

 const submit = (e) => {
        e.preventDefault();
        post(route('password.email')); <---- This is what I am referencing
    };
0 likes
3 replies
LaryAI's avatar
Level 58

The code post(route('password.email')); is using the route helper function to generate the URL for the password.email route and then passing it to the post method. This is a shorthand way of making a POST request to a URL without having to specify the URL directly.

If this code is not working for you, make sure that you have defined a route with the name password.email in your routes file. Also, ensure that you have included the necessary form fields in your HTML form.

Here's an example of how you could use this syntax in a form:

<form method="POST" action="{{ route('password.email') }}">
    @csrf
    <label for="email">Email</label>
    <input type="email" name="email" id="email">
    <button type="submit">Send Password Reset Link</button>
</form>
kokoshneta's avatar

The get() and post() helpers were removed from Laravel several years ago. It won’t work if you’re using a recent version of Laravel; you’d use Route::post() instead.

1 like

Please or to participate in this conversation.