Route handlers in Next.js
How do I use route handlers in next.js to post data to Xata?
console.loging your city and country before you send them to xata to see if they have values.
xata init) the columns won't be available in your local client file. The command "xata codegen" or "xata pull main" updates the client file with the latest schema from Xata.


JavaScript import syntax during "xata init"import { getXataClient } from "@/src/xata";
import { NextResponse } from "next/server";
const xata = getXataClient();
export async function POST(request) {
const { city, country } = request.body;
await xata.db.trips.create({
city,
country,
});
return NextResponse.json({ success: true });
}xata initJavaScript import syntax