This repository has been archived on 2024-10-02. You can view files and clone it, but cannot push or open issues or pull requests.
smart-tag/doc/3batchImport.js

59 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2021-03-10 15:27:43 +00:00
const express = require('express');
const got = require('got');
const config = require('./config');
const app = express();
const port = 9999;
app.get('/', async(req, res) => {
(async() => {
2021-03-18 10:38:05 +00:00
const info = await config.info;
let key = info.data.token;
2021-03-10 15:27:43 +00:00
let currentUser = info.data.currentUser;
(async() => {
2021-03-18 10:38:05 +00:00
const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', {
2021-03-10 15:27:43 +00:00
json: {
agencyId: currentUser.agencyId,
merchantId: currentUser.merchantId,
storeId: currentUser.storeId,
unitName: currentUser.unitName,
itemList: [{
2021-03-18 10:38:05 +00:00
attrCategory: 'default',
attrName: 'default',
barCode: '1000012345',
itemTitle: 'Australian apple',
originalPrice: '600',
price: '6300',
productArea: 'Britain',
productCode: '4151512414155',
productSku: '200001275',
},
{
attrCategory: 'default',
attrName: 'default',
barCode: '5141415414312',
itemTitle: 'Cavendish banana',
originalPrice: '10',
price: '8',
productArea: 'Brasil',
productCode: '4151512414156',
productSku: '20001536',
promotionText: 'sale'
}
2021-03-10 15:27:43 +00:00
]
},
responseType: 'json',
headers: {
2021-03-18 10:38:05 +00:00
'Authorization': key
2021-03-10 15:27:43 +00:00
}
2021-03-18 10:38:05 +00:00
});
console.log(body);
res.end(JSON.stringify(body));
2021-03-10 15:27:43 +00:00
})();
})();
});
app.listen(port, () => {
2021-03-18 10:38:05 +00:00
console.log(`Example app listening at http://localhost:${port}`);
});