fix: strip id/system fields before creating PB records
This commit is contained in:
parent
c1b98a6eca
commit
2d402c0482
1 changed files with 3 additions and 1 deletions
|
|
@ -86,11 +86,13 @@ export async function createRecord<T extends PBRecord>(
|
|||
collection: string,
|
||||
fields: Record<string, unknown>,
|
||||
): Promise<T> {
|
||||
// Strip id/system fields — let PB auto-generate them.
|
||||
const { id: _id, created: _c, updated: _u, ...safeFields } = fields;
|
||||
const url = `${BASE_URL}/api/collections/${collection}/records`;
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: { Authorization: TOKEN as string, "Content-Type": "application/json" },
|
||||
body: JSON.stringify(fields),
|
||||
body: JSON.stringify(safeFields),
|
||||
cache: "no-store",
|
||||
});
|
||||
if (!res.ok) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue