Next.js Discord

Discord Forum

route.ts missing in the nextjs.org formation

Answered
Hypcio posted this in #help-forum
Open in Discord
Hello guys, i'm learning next thanks to the nextjs.org website but the route.ts file in the /query is missing.
Can someone help me ?
ty
Answered by chisto
this should be in your query/route.ts

// import postgres from 'postgres';

// const sql = postgres(process.env.POSTGRES_URL!, { ssl: 'require' });

// async function listInvoices() {
//     const data = await sql`
//     SELECT invoices.amount, customers.name
//     FROM invoices
//     JOIN customers ON invoices.customer_id = customers.id
//     WHERE invoices.amount = 666;
//   `;

//     return data;
// }

export async function GET() {
  return Response.json({
    message:
      'Uncomment this file and remove this line. You can delete this file when you are finished.',
  });
  // try {
  //     return Response.json(await listInvoices());
  // } catch (error) {
  //     return Response.json({ error }, { status: 500 });
  // }
}


(got it from here https://github.com/vercel/next-learn/blob/main/dashboard/starter-example/app/query/route.ts)
View full answer

3 Replies

this should be in your query/route.ts

// import postgres from 'postgres';

// const sql = postgres(process.env.POSTGRES_URL!, { ssl: 'require' });

// async function listInvoices() {
//     const data = await sql`
//     SELECT invoices.amount, customers.name
//     FROM invoices
//     JOIN customers ON invoices.customer_id = customers.id
//     WHERE invoices.amount = 666;
//   `;

//     return data;
// }

export async function GET() {
  return Response.json({
    message:
      'Uncomment this file and remove this line. You can delete this file when you are finished.',
  });
  // try {
  //     return Response.json(await listInvoices());
  // } catch (error) {
  //     return Response.json({ error }, { status: 500 });
  // }
}


(got it from here https://github.com/vercel/next-learn/blob/main/dashboard/starter-example/app/query/route.ts)
Answer
Ty men !
you saved my day