Slide 51
Slide 51 text
Next.js
風
API
// api/update-post.ts
export default (req) => {
await env.db.exec([/*...*/]);
kv.delete(req.params.id).catch(console.error);
req.json({ok: true});
}
// pages/posts/[uuid].tsx
export const getStaticProps = async (ctx) => {
const id = ctx.params.uuid;
const posts = await env.db.get('select * from posts where id=$id', {$id:id});
return {
//
このページを破棄するタグ
cacheKeys: ['@app', '@posts', id],
props: { posts }
}
};