fix error messages not displaying toasts sometimes, add axios error interceptors

This commit is contained in:
Amruth Pillai
2023-01-18 21:36:05 +01:00
parent c9850b5815
commit 5024c19f87
8 changed files with 32 additions and 41 deletions

View File

@ -11,7 +11,6 @@ import Link from 'next/link';
import { useRouter } from 'next/router';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useEffect } from 'react';
import toast from 'react-hot-toast';
import { useMutation, useQuery } from 'react-query';
import Page from '@/components/build/Center/Page';
@ -69,17 +68,13 @@ const Preview: NextPage<Props> = ({ shortId }) => {
const layout: string[][][] = get(resume, 'metadata.layout', []);
const handleDownload = async () => {
try {
const url = await mutateAsync({
username: resume.user.username,
slug: resume.slug,
lastUpdated: dayjs(resume.updatedAt).unix().toString(),
});
const url = await mutateAsync({
username: resume.user.username,
slug: resume.slug,
lastUpdated: dayjs(resume.updatedAt).unix().toString(),
});
download(url);
} catch {
toast.error('Something went wrong, please try again later.');
}
download(url);
};
return (