Beginner: Cannot connect to R2 via Worker
Hi everyone, I followed the tutorial https://developers.cloudflare.com/r2/api/workers/workers-api-usage/ and created a worker. While testing it, I am getting an error:
If I remove the R2 related code, it works properly. I have tried both locally and after deployment. From CLI, I created the bucket as shown in the tutorial. I can see both the bucket and worker from the dashboard.
message:
"Cannot read properties of undefined (reading 'put')",
exception:
{
stack:
" at Object.fetch (index.js:971:30)",
name:
"TypeError",
message:
"Cannot read properties of undefined (reading 'put')",
timestamp:
1733778270490,
},If I remove the R2 related code, it works properly. I have tried both locally and after deployment. From CLI, I created the bucket as shown in the tutorial. I can see both the bucket and worker from the dashboard.
Cloudflare Docs
C3 (create-cloudflare-cli) is a command-line tool designed to help you set up and deploy Workers & Pages applications to Cloudflare as fast as possible.
