GET request caching the response
Unanswered
Hygen Hound posted this in #help-forum
Hygen HoundOP
Hi, I have this function
It works as intended, but when I update the database, it doesn't show the updated values
export const dynamic = "force-dynamic";
import { NextResponse } from "next/server";
import { sql } from "@vercel/postgres";
export async function GET(request, { params }) {
const slug = params.slug;
try {
const { rows } = await sqlSELECT * FROM bar_users WHERE id = ${slug};;
console.log(rows);
if (rows.length == 0) {
return NextResponse.json({
error: "No user with such id found",
});
} else {
return NextResponse.json({
name: rows[0]?.name,
points: rows[0]?.points,
classe: rows[0]?.classe,
});
}
} catch (e) {
return NextResponse.json({
error: e.code,
});
}
}It works as intended, but when I update the database, it doesn't show the updated values