1. Create a Worker 2. Click into the Worker, visit the Settings tab, and click the Variables submenu

1. Create a Worker
2. Click into the Worker, visit the Settings tab, and click the Variables submenu scroll down to "D1 Database Bindings", and add your D1 database (I called mine DB)
3. Quick edit the Worker, (to test this works, I used this:)
export default {
  async fetch(request, env, ctx) {
    const res = await env.DB.prepare('SELECT 1;').all()
    return new Response(JSON.stringify(res, null, 2));
  },
};

4. Hit Send on the right hand side
5. You should see JSON output similar to:
{
....
"results": [
    {
      "1": 1
    }
  ]
}
Was this page helpful?