Ranwrangler dev并且它似乎沒有系結 Worker KV:
ERROR in /src/handler.ts
./src/handler.ts 16:8-17
[tsl] ERROR in /src/handler.ts(16,9)
TS2304: Cannot find name 'generalKV'.
這是handler.ts:
async function postHandler(request: Request): Promise<Response> {
let content = JSON.stringify(await request.json());
await generalKV.put([Date.now().toString()], JSON.stringify(content));
return new Response(content);
}
wrangler.toml:
name = "general-assignment"
type = "javascript"
account_id = "<id>"
workers_dev = true
compatibility_date = "2021-11-01"
kv_namespaces = [
{ binding = "generalKV", id = "<id>", preview_id = "<id>" }
]
有人建議kv_namespaces改為kv-namespaces,但對我不起作用。如果我錯過了什么,請通知我。
uj5u.com熱心網友回復:
您是否已經在 Cloudflare 上手動創建了 KV 命名空間?我不相信它會從 worker 中的系結設定動態創建它們(還)。
通過 Wrangler 創建的檔案 -
https://developers.cloudflare.com/workers/cli-wrangler/commands#create
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/343884.html
