Running a a script that pull a test page and injects some hreflang links into the header.
For the life of me I can't get the binding to work to the KVs that hold the links to be added.
I added the KV to the Variables in Settings.
edit: I have tried more setting styles like this one
and called env.KVStuff but still there is no connection. Still getting no connection errors TypeError: Cannot read properties of undefined (reading 'KVStuff')
Even just putting all the KV code in one place doesn't work
addEventListener("fetch", (event,env, ctx) => {
console.log("Got event");
var getData = () => env.NAMESPACE;
let data = getData().get("1home");
console.log("getData", data);
event.respondWith(handleRequest(event.request));
});
I get worker.js:233 TypeError: Cannot read properties of undefined (reading 'NAMESPACE')
I'm getting pretty desperate here.
Solved!
Just take the env off the namespace code and it works