부동산 정보 api 오류 해결
This commit is contained in:
@@ -1055,11 +1055,21 @@ const Subscription = () => {
|
||||
};
|
||||
|
||||
const handleAdd = async (data) => {
|
||||
const n = { ...data, id: Date.now() };
|
||||
const next = [...items, n];
|
||||
persist(next);
|
||||
const tempId = Date.now();
|
||||
const n = { ...data, id: tempId };
|
||||
persist([...items, n]);
|
||||
setShowSubModal(false);
|
||||
try { await apiPost('/api/subscription/items', data); } catch {}
|
||||
try {
|
||||
const res = await apiPost('/api/subscription/items', data);
|
||||
if (res?.id) {
|
||||
// 서버가 부여한 실제 DB ID로 교체
|
||||
setItems((prev) => {
|
||||
const updated = prev.map((i) => (i.id === tempId ? { ...i, id: res.id } : i));
|
||||
localStorage.setItem('sub_items', JSON.stringify(updated));
|
||||
return updated;
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
};
|
||||
|
||||
const handleUpdate = async (data) => {
|
||||
|
||||
Reference in New Issue
Block a user