I have a D1 database bound to a Cloudflare Pages and the object context.env.SQLITE
is empty. The code works fine locally via mini flare, but when deployed it says that SQLITE.prepare
is not a function, well, because the SQLITE object is empty. Any thoughts?
export const home = async (context) => {
// https://developers.cloudflare.com/d1/changelog
const db = context.env.SQLITE || context.env.__D1_BETA__SQLITE;
console.log(JSON.stringify(db));
const { results } = await db.prepare(`
select * from posts
`).all();
// etc.