diff options
author | 2022-10-18 15:52:49 +0200 | |
---|---|---|
committer | 2022-10-18 09:52:49 -0400 | |
commit | 5923dd77c17c80747f9fe746ff8270ad4c820003 (patch) | |
tree | 23611ba030bb4d940660821efdd8a2448fc88733 /examples/ssr/src/pages/login.form.async.ts | |
parent | 04ce7f4e5c49c16302baacbfbdec38da1bb8d4c3 (diff) | |
download | astro-5923dd77c17c80747f9fe746ff8270ad4c820003.tar.gz astro-5923dd77c17c80747f9fe746ff8270ad4c820003.tar.zst astro-5923dd77c17c80747f9fe746ff8270ad4c820003.zip |
adding cookies to api route response [simple result] (#5060)
* adding cookies to the an api route response, also when returning a simple result
* in dev server, convert a simple endpoint result into a response object
Co-authored-by: AirBorne04 <unknown>
Co-authored-by: AirBorne04 <>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Diffstat (limited to 'examples/ssr/src/pages/login.form.async.ts')
-rw-r--r-- | examples/ssr/src/pages/login.form.async.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/ssr/src/pages/login.form.async.ts b/examples/ssr/src/pages/login.form.async.ts new file mode 100644 index 000000000..f98b11cfe --- /dev/null +++ b/examples/ssr/src/pages/login.form.async.ts @@ -0,0 +1,16 @@ +import { APIContext, APIRoute } from 'astro'; + +export const post: APIRoute = ({ cookies, params, request }: APIContext) => { + // add a new cookie + cookies.set('user-id', '1', { + path: '/', + maxAge: 2592000, + }); + + return { + body: JSON.stringify({ + ok: true, + user: 1, + }), + }; +}; |