I’m learning to read database from vercel from this tutorial (@vercel/postgres).
In a simple array, I manage to call simple arrays using var.map
, but how to do it when I want to use vercel postgres?
this is my current effort, trying to display data from vercel
import { createClient } from '@vercel/postgres';
export async function queryPosts(request: Request) {
const { searchParams } = new URL(request.url);
const petName = searchParams.get('petName');
const client = createClient();
await client.connect();
try {
const { rows, fields } =
await client.sql`SELECT * FROM pets WHERE name > ${petName};`;
} finally {
await client.end();
}
}
How to call data using url similar to add-data example/tutorial?
New contributor
Dwipa Arantha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.