trithuc-mvc-react 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.js +2 -3
- package/package.json +1 -1
package/api/index.js
CHANGED
|
@@ -58,7 +58,6 @@ export const getDatasFromTable = async ({ tableName, page, pageSize, data }) =>
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
|
|
62
61
|
return res.data;
|
|
63
62
|
} catch (error) {
|
|
64
63
|
console.error("Error fetching data:", error);
|
|
@@ -124,13 +123,13 @@ export const saveDataToTable = async ({ tableName, data }) => {
|
|
|
124
123
|
});
|
|
125
124
|
return res.data;
|
|
126
125
|
} else {
|
|
127
|
-
if (!data.
|
|
126
|
+
if (!data.Id) {
|
|
128
127
|
// Khi không có ID, thực hiện POST đến apiUrl
|
|
129
128
|
const res = await api.post(`${getBaseUrl()}/${apiUrl}/${tableName}`, data);
|
|
130
129
|
return res.data;
|
|
131
130
|
} else {
|
|
132
131
|
// Khi có ID, thực hiện PUT đến apiUrl với ID trong URL
|
|
133
|
-
const res = await api.put(`${getBaseUrl()}/${apiUrl}/${tableName}/${data.
|
|
132
|
+
const res = await api.put(`${getBaseUrl()}/${apiUrl}/${tableName}/${data.Id}`, data);
|
|
134
133
|
return res.data;
|
|
135
134
|
}
|
|
136
135
|
}
|