Hey, guys am stack with updating user password with react front end and devise, plus axios which am using to post that on an api.
i have not changed anything from devise but when i hit the api the password is updated and i can use it for login but when i look at the terminal their is an error of ActionController::RoutingError (No route matches [PUT] "/")
any help is highly appreciated
const onFinish = (values) => { setLoading(true); const session = { "user": { ...values, reset_password_token: params.get("reset_password_token") } } const path = "/users/password" setAxiosHeaders(); axios.put(path, session) .then((response) => { console.log(response.data) }) .catch((error) => { console.log(error); }) }
- when i hit the api it looks like it is being twice as it throws the same error.
- I have tried PATCH method also the same story.
Javascript requests (xhr / fetch) redirect with the same http method as original request. You're sending a PUT request and your controller redirects to the root url
/, request to the redirected url is issued with a PUT method.Use status
:see_other(aka303) to redirect with a GET method:You can set these options:
But it's probably best to set it up for a json response to begin with instead of html.
https://github.com/waiting-for-dev/devise-jwt/wiki/Configuring-devise-for-APIs