In Remix, how do you return json
first and then redirect
after a success call on the API?
export const action: ActionFunction = async ({
request,
}: ActionFunctionArgs) => {
const formData = await request.formData();
try {
const { project } = await sampleAPICall(formData);
return json({
title: "Success",
message: "Yehey!",
});
throw redirect(`/${project?.id}`);
} catch (error) {
return json({
variant: "destructive",
message: "Oh no....",
});
}
};