How to redirect to a new route, only on success of a REST API Call? #3466
Unanswered
RajaTheKing826
asked this question in
Q&A
Replies: 1 comment
-
You need to await your REST API call and return a redirect after that export let action: ActionFunction = async () => {
try {
await doYourApiRequest()
return redirect("/somewhere/else") // this will happen after doYourApiRequest
} catch (error) {
// this will happen if doYourApiRequest failed
throw json({ message: error.message }, 400)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to redirect to another route only after successful completion of the REST Api that i have written in action. In the docs i have seen that they are simply redirecting irrespective of the API call success, but in my case i want redirection only on success of API that i have written
Beta Was this translation helpful? Give feedback.
All reactions