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
Catt0s
Catt0s12mo ago
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.
Catt0s
Catt0s12mo ago
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
export async function onRequestGet(context) {
console.log(context.Request.url);
return new Response("");
}
export async function onRequestGet(context) {
console.log(context.Request.url);
return new Response("");
}
Hello, I’m Allie!
Try context.request.url, note the lowercase request
Catt0s
Catt0s12mo ago
I 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
"exceptions": [
{
"name": "Error",
"message": "D1_ERROR"
"timestamp": (time)
}]
"exceptions": [
{
"name": "Error",
"message": "D1_ERROR"
"timestamp": (time)
}]
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/
Want results from more Discord servers?
Add your server
More Posts