I am unable to get the KV values working locally.
I did the following:
- created a kv binding under my develop env
- created a key with --env=develop and --local
- I am able to retrieve the key w/o any issue w/ --local flag
- with wrangler dev, I always get “null”
[env.develop]
kv_namespaces = [
{ binding = "KV_DOMAINS", id = "42424242424242424242", preview_id = "42424242424242424242" }
]
wrangler kv:key --env=develop --binding=KV_DOMAINS --local --preview false put koko "this is the value"
wrangler kv:key --env=develop --binding=KV_DOMAINS --local --preview false get koko
this is the value
wrangler dev --env=develop --local src/test_kv.ts
export interface Env {
KV_DOMAINS: KVNamespace;
}
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const koko = await env.KV_DOMAINS.get("koko");
console.log(koko);
return new Response(`this is it ${koko}`);
}};