Skip to content

Commit

Permalink
Fix book order in GET request
Browse files Browse the repository at this point in the history
  • Loading branch information
matteotagliatti committed Nov 17, 2023
1 parent 8c98a8a commit 67f54fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/routes/api/books/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const GET: RequestHandler = async ({ url, locals: { supabase } }) => {
const username = String(url.searchParams.get("username"));
const status = String(url.searchParams.get("status"));
const limit = Number(url.searchParams.get("limit") || 10);
const order = String(url.searchParams.get("order") || "updated_at");

if (!username) {
throw error(400, "username is required");
Expand All @@ -29,7 +30,7 @@ export const GET: RequestHandler = async ({ url, locals: { supabase } }) => {
.select()
.eq("owner", user.id)
.eq("status", status)
.order("finished", { ascending: false })
.order(order, { ascending: false })
.limit(limit);

if (books_error) throw error;
Expand Down

1 comment on commit 67f54fb

@vercel
Copy link

@vercel vercel bot commented on 67f54fb Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.