Refactor CSV import API call in CSVImportDialog to use a structured request body. Increase JSON payload limit in index.js to support larger CSV imports.
This commit is contained in:
@@ -138,11 +138,14 @@ class CSVImportDialog extends Component {
|
|||||||
this.setState({ importing: true, error: null });
|
this.setState({ importing: true, error: null });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await this.authService.apiCall('/data/import-csv-transactions', 'POST', {
|
const response = await this.authService.apiCall('/data/import-csv-transactions', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
transactions: csvData,
|
transactions: csvData,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
filename: file.name,
|
filename: file.name,
|
||||||
batchId: `import_${Date.now()}_${file.name}`
|
batchId: `import_${Date.now()}_${file.name}`
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response && response.ok) {
|
if (response && response.ok) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const PORT = process.env.PORT || 5000;
|
|||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json({ limit: '10mb' })); // Increased limit for CSV imports
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
app.use('/api/auth', authRoutes);
|
app.use('/api/auth', authRoutes);
|
||||||
|
|||||||
Reference in New Issue
Block a user