Cannot access KV namespace locally
Hi. How i can access KV data locally in pages? It always returns null. It works on production. however locally does not.
wrangler pages dev --local-protocol=http --compatibility-flag=nodejs_compat --compatibility-date=2023-06-22 --proxy 5173 --binding MODE='development' --kv=<namespace> -- npm run dev
Using this in terminal returns correct keys.
wrangler kv:namespace list
Basic functions code i am using:
export async function onRequest(context) {
const test = await context.env.NAMESPACE.get('key')
return new Response(JSON.stringify(test))
}
Thanks1 Reply
Try without the equals? I do this for three KV namespaces
--kv KV_SMN_GENERAL KV_SMN_MAGIC_LINKS KV_SMN_SESSIONS