Update index.html
1 file changed+5−5
index.html+5−5View file
| @@ -1503,19 +1503,19 @@ | ||
| try { | ||
| const payload = cleanPayload(data); | ||
| if (data._id && !isTempId(data._id)) { | ||
| - const updateRes = await apiFetch(`/api/${endpoint}/${data._id}`, { | ||
| + const updateRes = await apiFetch(`/api/p/${PROJECT_ID}/tables/${endpoint}/rows/${data._id}`, { | ||
| method: 'PATCH', | ||
| body: JSON.stringify(payload) | ||
| }); | ||
| - if (updateRes.ok) return await updateRes.json(); | ||
| + if (updateRes.ok) return unwrapRow(await updateRes.json()); | ||
| } | ||
| - const createRes = await apiFetch(`/api/${endpoint}`, { | ||
| + const createRes = await apiFetch(`/api/p/${PROJECT_ID}/tables/${endpoint}/rows`, { | ||
| method: 'POST', | ||
| body: JSON.stringify(payload) | ||
| }); | ||
| if (createRes.ok) { | ||
| - const resData = await createRes.json(); | ||
| - if (resData._id && data._id && isTempId(data._id)) { | ||
| + const resData = unwrapRow(await createRes.json()); | ||
| + if (resData && resData._id && data._id && isTempId(data._id)) { | ||
| data._id = resData._id; | ||
| } | ||
| return resData; | ||