Skip to content

Commit

Permalink
fix: loader
Browse files Browse the repository at this point in the history
  • Loading branch information
RamK777-stack committed May 19, 2024
1 parent 94b7f98 commit eac80ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ const Editor = dynamic(() => import('@/app/components/Editor'), {
// Before you begin editing, follow all comments with `STARTERCONF`,
// to customize the default configuration.

const saveData = async (payload: OutputData) => {
const fetchAndParse = async (payload: OutputData) => {
const response = await fetch('/api/pastes', {
method: 'POST',
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error('Failed to save data');
}
const promise = new Promise((resolve) => resolve(response.json()));
return await response.json();
};

toast.promise(promise, {
const saveData = async (payload: OutputData) => {
toast.promise(fetchAndParse(payload), {
loading: 'Loading...',
success: (data: PasteResponse) => {
navigator.clipboard.writeText(
Expand Down

0 comments on commit eac80ef

Please sign in to comment.