0

I would like to make a good query that I have not been able to solve anywhere, I need to use a plugin that prints to a thermal printer, but it throws me an error connect ECONNREFUSED 127.0.0.1:8000, first I had CORS problems and looking for it I solved it but I am left with that problem, I leave the code for more idea.

async imprimirEn(nombreImpresora) {
  const payload = {
    operaciones: this.operaciones,
    nombreImpresora,
  };
  const { data } = await axios.post(
    "/api/print/print",
    //// JSON.stringify(payload)
    payload
  );
  return data;

I had to call it this way to the next API, since it otherwise threw the cors error, so the call looked like this:

const print = nc().use(cors()).post(async (req, res) => {
  const body = req.body;
  console.log("mensaje desde nc:", body);
  const { data } = await axios.post(
    "http://localhost:8000/imprimir",
    JSON.stringify(body)
  );
  res.json(data)
});

export default print;
juliomalves
  • 42,130
  • 20
  • 150
  • 146

0 Answers0