Interacting with D1 database with URL query
Hello,
I want to build my pages website to show page contents based on the URL query. I made a D1 database and a function. But I am inexperienced with this stuff, and would like help. I know that functions run server-size, and therefore cannot get the
window
for the URL parameters, how else can I do this?4 Replies
i am trying to use this rn but its not working https://developers.cloudflare.com/workers/runtime-apis/request/
Request · Cloudflare Workers docs
The Request interface represents an HTTP request and is part of the Fetch API.
Well the fact that
context.requests
is {}
doesn't help
context.request.url
throws an exception
which is why i have been confused this whole time, because in the real-time logs the debug isnt'
typeError: Cannot read properties of undefined (reading 'url')
Yes, but be warned I am bad at js
Try
context.request.url
, note the lowercase requestI think i tried that but i will try again
How do I use placeholders?
context.env.DB.query(myQuery, [myVars])
says query is undefined?
i have no idea what i am doing tbh
oh wait
yeah how do i do placeholders here, I have
prepare` returning but trying to use placeholders breaks
oh bind???
https://developers.cloudflare.com/d1/platform/client-api/