telesto🌛T
Deno12mo ago
1 reply
telesto🌛

API server with Postgres on Deno Deploy ConnectionParamsError

Hi everyone,

I’ve been following the "API server with Postgres" tutorial (https://docs.deno.com/deploy/tutorials/tutorial-postgres/) and have set everything up successfully. For my project, I decided to go with Supabase. However, when I try to test the setup in the playground, I’m running into an error:
ConnectionParamsError: Missing connection parameters: database
at assertRequiredOptions (https://deno.land/x/postgres@v0.19.3/connection/connection_params.ts:250:11)
at createParams (https://deno.land/x/postgres@v0.19.3/connection/connection_params.ts:538:3)
at new Pool (https://deno.land/x/postgres@v0.19.3/pool.ts:100:31)
at file:///src/main.ts:11:14

this isn't mentioned anywhere how you would to this, the only env variable I've set is the one mentioned in the tutorial, has anyone tried this one before and can help me?

I even tried a slightly different setup which fails in the same way
import { Pool } from "https://deno.land/x/postgres@v0.19.3/mod.ts";

Deno.serve(async (req) => {
  return new Response("Not Found", { status: 404 });
});

// Get the connection string from the environment variable "DATABASE_URL"
const databaseUrl = Deno.env.get("DATABASE_URL")!;

// Create a database pool with three connections that are lazily established
const pool = new Pool(databaseUrl, 3, true);

Deno.serve(async (_req) => {
  try {
    // Grab a connection from the pool
    const connection = await pool.connect()
 
    try {
      // Run a query
      const result = await connection.queryObject`SELECT * FROM animals`
      const animals = result.rows 
    } finally {
      // Release the connection back into the pool
      connection.release()
    }
  } catch (err) {
    console.error(err)
    return new Response(String(err?.message ?? err), { status: 500 })
  }
})

The screenshot is displayed next to the playground editor
image.png
Was this page helpful?