Improve error handling by creating a function handler for connections on servers that use KY, and use the status key in the response as the key to success instead of catch. Use catch if an error occurs between the client and server, not between the server and backend.
12 lines
229 B
TypeScript
12 lines
229 B
TypeScript
import { useRouter } from "next/navigation";
|
|
|
|
export const delayButtonClick = (
|
|
router: ReturnType<typeof useRouter>,
|
|
href: string,
|
|
timeout: number = 300
|
|
) => {
|
|
setTimeout(() => {
|
|
router.push(href);
|
|
}, timeout);
|
|
};
|