Skip to content

Commit

Permalink
checking error when post is fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
Gautham-kj committed Oct 26, 2023
1 parent a8b94ff commit 16e1423
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/routes/post/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ export async function load({ params, locals }) {
console.log(res);
if (res.error) {
// throwing error for user not found
console.log(res.error);
throw error(400, 'Post Not Found');
} else {
if (res.data) {
console.log(res.data);
return res.data;
}
}
}
}
//throwing error for invalid user id
throw error(400, 'Invalid User ID');
throw error(400, 'Not Logged in ');
}

0 comments on commit 16e1423

Please sign in to comment.