const express = require('express'); const router = express.Router(); // eslint-disable-line const selectTicket = require('../db/selectTicket'); const config = require('../config'); const dataLogIn = require('../server'); const got = require('got'); router.get('/:ticket', async(req, res) => { const ticketId = req.params.ticket; const ticket = selectTicket(ticketId); await insertFlash(ticket); res.json({message: 'SUCCESS'}); }); module.exports = router; 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 json: { storeId: config.storeId, lightCololr: 8, lightTime: 30, targetExecution: ticket[0].shelvingFk + ticket[0].level + '/tagWithTicket', lightFrequency: 1 }, responseType: 'json', headers: { 'Authorization': key } }); }