From 60e39d9e1aeb56045a7bab68911edece9dcd3d79 Mon Sep 17 00:00:00 2001 From: Hou Samnang Date: Tue, 30 Mar 2021 11:28:16 +0700 Subject: [PATCH] Fix style --- src/index.js | 12 +++++------- src/upload.html | 30 ++++++++++++++---------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/index.js b/src/index.js index d7b9377..bad0cbf 100644 --- a/src/index.js +++ b/src/index.js @@ -25,7 +25,7 @@ app.get('/', function (req, res) { res.sendFile('/upload.html', { root: __dirname }) }); -let port = 4000 +let port = 5000 app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) }) @@ -36,13 +36,11 @@ var XLSX = require('xlsx') app.use(upload.none()); app.post('/upload', async function (req, res) { let input = req.body.myFile; - - let wb = XLSX.read(input, {type : 'binary'}); + let wb = XLSX.read(input, { type: 'binary' }); - let xlData = XLSX.utils.sheet_to_json(wb.Sheets['Sheet1']); - let data = xlData.map((row) => ({ id: row.No, name: row['Product name'] })) + let xlData = XLSX.utils.sheet_to_json(wb.Sheets['Sheet2']); + let data = xlData.map((row) => ({ productName: row['Product name'], smallTypeName: row.smallTypeName, productCategory: { productCategoryId: row['CategoryID'] }, alert: row.alert, cost: row.cost, qtyStock: row.qtystock, sellPrice: row.sellPrice })) res.send(data) - console.log('dawdaw', data) }) - + diff --git a/src/upload.html b/src/upload.html index e985b08..c686dbd 100644 --- a/src/upload.html +++ b/src/upload.html @@ -7,27 +7,25 @@



- +