Skip to content
Discussion options

You must be logged in to vote

You're using a regular Form to post to an API route. Form will "navigate" to the action route. After a POST, Remix will then revalidate your routes by calling your loaders. That's why you are seeing a GET request to your API route.

You should either create a UI route for login (i.e., export a default component), or use a fetcher.Form. useFetcher() does NOT do navigation, so it'll do the POST and return the data while staying on the current route.

const fetcher = useFetcher()
// access fetcher.data

return (
  <fetcher.Form method="post" action="/api/login">
    ...
)

https://remix.run/docs/en/v1/api/remix#fetcherform

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DKeen0123
Comment options

Answer selected by DKeen0123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants