diff --git a/src/index.js b/src/index.js index 737eb00..dd37ff9 100644 --- a/src/index.js +++ b/src/index.js @@ -41,10 +41,13 @@ app.post('/upload', async function (req, res) { let wb = XLSX.read(input, { type: 'binary' }); 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 })) + let data = xlData.map((row) => ({ productName: row['Product name'], smallTypeName: row.SmallTypeName, productCategory: { productCategoryId: row['CategoryID'], newCategory: row['Category'] }, alert: row.alert, cost: row.cost, qtyStock: row.qtystock, sellPrice: row.sellPrice })) res.send(data) + var fileData = JSON.stringify(data) + console.log(fileData) + axios({ url: 'http://localhost:4000/graphql', method: 'post', @@ -54,9 +57,9 @@ app.post('/upload', async function (req, res) { data: { query: ` mutation{ - createManyProducts(file: "${JSON.stringify(data)}") + createManyProducts(file: ${JSON.stringify(fileData)}) } - ` + `, } }).then((result) => { console.log(result.data)