fix(export): update frontend to call new /admin/db/export endpoint
- Changed exportSnapshot to call GET /api/admin/db/export?type=inventory - Changed exportAuditTrail to call GET /api/admin/db/export?type=audit - Fixed token key: auth_token → inventory_token - Changed HTTP method from POST to GET - Fixes 404 errors when exporting from admin page
This commit is contained in:
@@ -49,10 +49,9 @@ export function useExport(): UseExportReturn {
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const token = localStorage.getItem('auth_token');
|
||||
const response = await axios.post(
|
||||
`/api/admin/exports/inventory-snapshot?format=${format}`,
|
||||
{},
|
||||
const token = localStorage.getItem('inventory_token');
|
||||
const response = await axios.get(
|
||||
`/api/admin/db/export?format=${format}&type=inventory`,
|
||||
{
|
||||
responseType: "blob",
|
||||
headers: { 'Authorization': `Bearer ${token}` }
|
||||
@@ -85,10 +84,9 @@ export function useExport(): UseExportReturn {
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const token = localStorage.getItem('auth_token');
|
||||
const response = await axios.post(
|
||||
`/api/admin/exports/audit-trail?format=${format}`,
|
||||
{},
|
||||
const token = localStorage.getItem('inventory_token');
|
||||
const response = await axios.get(
|
||||
`/api/admin/db/export?format=${format}&type=audit`,
|
||||
{
|
||||
responseType: "blob",
|
||||
headers: { 'Authorization': `Bearer ${token}` }
|
||||
|
||||
Reference in New Issue
Block a user