Getting 409 conflict error in inertia response #6
-
Handler: func (h *LoginInertiaHandler) ProcessLogin(ctx echo.Context) error {
errCtx := gonertia.WithValidationError(ctx.Request().Context(), "email", "Invalid email address")
req := ctx.Request().WithContext(errCtx)
println(errCtx)
i := middleware.GetInertia(ctx)
i.Back(ctx.Response(), req)
return nil
} This results in a 409 conflict, am i doing anything wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
I've learned that it only happens with i.Back() |
Beta Was this translation helpful? Give feedback.
-
Also, this is how i make the request: const { data, setData, post, processing, errors, } = useForm({
email: '',
password: '',
});
const handleSubmit = (e: MouseEvent) => {
e.preventDefault();
post('/login');
} |
Beta Was this translation helpful? Give feedback.
-
So what is the gonertia idiomatic way to just return a response with errors back to login? |
Beta Was this translation helpful? Give feedback.
-
Inertia-laravel uses session to store the errors and then reloads the page |
Beta Was this translation helpful? Give feedback.
-
for now this works: func (h *LoginInertiaHandler) ProcessLogin(ctx echo.Context) error {
errCtx := gonertia.WithValidationError(ctx.Request().Context(), "email", "Invalid email address")
ctx.SetRequest(ctx.Request().WithContext(errCtx))
return h.RenderLoginPage(ctx)
} But this only works easily if the form endpoint is a subroute or the post version of the other route, since if it requires any parameters these should be available in the form submission endpoint too. You can also use a session based system to pass errors |
Beta Was this translation helpful? Give feedback.
-
Added |
Beta Was this translation helpful? Give feedback.
Added
FlashProvider
in v1.1.8 version. Updated README.md.