const express = require('express'); const router = express.Router(); // eslint-disable-line const select = require('../db/selectTicket'); router.get('/:ticket', async(req, res) => { const ticket = req.params.ticket; console.log(ticket); searchTicket(ticket); res.json({message: 'SUCCESS'}); }); module.exports = router; function searchTicket(ticket) {// parametro ticketFk select.select(ticket, function(err, data) { console.log(data); insertFlash(data); }); } function insertFlash(consultaSql) { console.log('CONSULTASQL_TAMAÑO:', consultaSql.length); const dataLogIn = require('../server'); const got = require('got'); (async() => { const info = await dataLogIn.dataLogIn; let key = info.data.token; let currentUser = info.data.currentUser; (async() => { const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { // eslint-disable-line json: { agencyId: currentUser.agencyId, merchantId: currentUser.merchantId, storeId: currentUser.storeId, unitName: currentUser.unitName, itemList: [ { attrCategory: 'verdnatura', attrName: 'conTicket', barCode: consultaSql[0].shelvingFk + consultaSql[0].level, // Matricula + nivel itemTitle: 'Etiqueta Con ticket', productCode: consultaSql[0].ticketFk, // Ticket qrCode: consultaSql[0].ticketFk, custFeature1: consultaSql[0].clientFk, // Cliente custFeature2: consultaSql[0].agencyFk, // Agencia de transporte custFeature3: 1, // Luz LED custFeature4: '', // consultaSql[0].workerFk, // Trabajador custFeature5: consultaSql[0].wagon, // Wagon } ] }, responseType: 'json', headers: { 'Authorization': key } }); console.log(body); })(); })(); }