feat(flashOn): change options and error handling
gitea/smart-tag/pipeline/head This commit looks good
Details
gitea/smart-tag/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b113636e9c
commit
e92104f55a
|
@ -8,7 +8,10 @@ const got = require('got');
|
|||
router.get('/:ticket', async(req, res) => {
|
||||
const ticketId = req.params.ticket;
|
||||
|
||||
const ticket = selectTicket(ticketId);
|
||||
const [ticket] = await selectTicket(ticketId);
|
||||
if (!ticket.length)
|
||||
res.status(400).json({error: {code: 'flashError', message: 'Este ticket no está asociado'}});
|
||||
|
||||
await insertFlash(ticket);
|
||||
|
||||
res.json({message: 'SUCCESS'});
|
||||
|
@ -20,17 +23,20 @@ async function insertFlash(ticket) {
|
|||
const info = await dataLogIn.dataLogIn;
|
||||
const key = info.data.token;
|
||||
|
||||
await got.post('http://app.etiquetaselectronicas.com:9999/led/excuteLed', { // eslint-disable-line
|
||||
const response = await got.post('http://app.etiquetaselectronicas.com:9999/led/excuteLed', { // eslint-disable-line
|
||||
json: {
|
||||
storeId: config.storeId,
|
||||
lightCololr: 8,
|
||||
lightTime: 30,
|
||||
lightCololr: 2,
|
||||
lightTime: 10,
|
||||
targetExecution: ticket[0].shelvingFk + ticket[0].level + '/tagWithTicket',
|
||||
lightFrequency: 1
|
||||
brightness: 80,
|
||||
lightFrequency: 2
|
||||
},
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Authorization': key
|
||||
}
|
||||
});
|
||||
if (!response.body.success)
|
||||
res.status(400).json({error: {code: 'flashError', message: response.body.message}});
|
||||
}
|
||||
|
|
Reference in New Issue