Skip to content

Commit

Permalink
Merge pull request #147 from denoland/feat-redirect-to-item-page
Browse files Browse the repository at this point in the history
feat: redirect to item page after submission
  • Loading branch information
iuioiua authored May 2, 2023
2 parents 624466f + 30067d7 commit 86f7541
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions routes/submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ export const handler: Handlers<State, State> = {
return new Response(null, { status: 400 });
}

await createItem({
const item = await createItem({
userId: ctx.state.session!.user.id,
title,
url,
});

return ctx.render(ctx.state);
return new Response(null, {
headers: { location: `/item/${item!.id}` },
status: 302,
});
},
};

Expand Down

0 comments on commit 86f7541

Please sign in to comment.