Skip to content
Snippets Groups Projects
Commit 5479b687 authored by Tim-Luca Taxis's avatar Tim-Luca Taxis
Browse files

added

parent ff847c07
No related branches found
No related tags found
1 merge request!4added vercel integration
...@@ -15,7 +15,6 @@ export default async function handler(request, response) { ...@@ -15,7 +15,6 @@ export default async function handler(request, response) {
`; `;
const { rows: fruits } = await sql`SELECT * FROM obst;`; const { rows: fruits } = await sql`SELECT * FROM obst;`;
return response.status(200).json(fruits); return response.status(200).json(fruits);
} catch (error) { } catch (error) {
console.error('Error during request processing:', error); console.error('Error during request processing:', error);
......
import { sql } from '@vercel/postgres'; import { sql } from '@vercel/postgres';
export default async function handler(request, response) { export default async function handler(request, response) {
if (request.method === 'POST') {
try { try {
const result = await sql` const result = await sql`
CREATE TABLE IF NOT EXISTS obst ( CREATE TABLE IF NOT EXISTS obst (
"Deutscher Name" varchar(50) NOT NULL, "Deutscher Name" varchar(50) NOT NULL,
"Lateinischer Name" varchar(50) NOT NULL, "Lateinischer Name" varchar(50) NOT NULL,
Farbe varchar(50) NOT NULL, Farbe varchar(50) NOT NULL,
Herkunft varchar(200) NOT NULL, Herkunft varchar(200) NOT NULL,
Kalorien int NOT NULL Kalorien int NOT NULL
);`; );
return response.status(200).json({ result }); `;
return response.status(200).json({ result });
} catch (error) { } catch (error) {
console.error('Error creating table:', error); console.error('Error creating table:', error);
return response.status(500).json({ error: error.message }); return response.status(500).json({ error: error.message });
} }
} else {
return response.status(405).json({ message: 'Method Not Allowed' });
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment