D1 example integration broken when initializing with wrangler API
Hi, I created the worker example through the cloudflare dashboard, selected edit, and then found the command to initialize with wrangler for local development.
After a bit of trial and error I found out the command was not --from-dash, but rather a newer command.
npm create cloudflare pegs-api -- --existing-script pegs-api
After doing this, I got a nice workspace initializing and all was good, until I tried running npm run deploy
in the root folder of the project.
Then I got binding DATABASE of type d1 must have an
id specified [code: 10021]
i tried added the same database uuid to preview_database_id
as that seemed to have solved a similar, but not identical issue, but that did not solve anything from me. I Added that in both the ./wrangler.toml
and ./src/wrangler.toml
.
I have not made any other changes to the example. It seems like 10021 can be caused by all sorts of API misshaps, can you provide any guidance? 🙂 Thanks!1 Reply
I found out the issue. The code generated is not correct. Rather using unsafe bindings it should use
That at least solved it for me