How to access the D1 without the Wrangler ?

I create the Worker via Cloudflare API and it is not possible to create wrangler.toml The code contains: addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)); }); ... But how can I access the D1 database ?
2 Replies
Cyb3r-Jak3
Cyb3r-Jak35mo ago
I don't believe D1 works on service workers. You would have to switch to module workers
Jonathan Silva
Jonathan SilvaOP5mo ago
Would I need the wrangler.toml file ? If so, there is no way to create this file via the API I used this code for testing and it gives me the following error Unexpected token 'export' at worker.js export default { async fetch(request, env, ctx) { const res = await env.DB.prepare("SELECT 1;").all(); return new Response(JSON.stringify(res, null, 2)); }, };
Want results from more Discord servers?
Add your server