'I was using node mongo db now I try to use the same database in mysql with sequelize using async await but I have this problem... plaese

I just want to consult a table of products wanted to know if it can be used with async await in javascript with nodejs express and sequelize it is a api


     import { ProductoModel } from "../models/ProductoModel.js";
        const listar = async (req,res) => {
        try {
                const listaProductos = await ProductoModel.findAll();
                res.send({msg: "lista de productos"});
                res.json(listaProductos);
            } catch (error) {
                res.json({msg: error.msg});
            }
        };
        export {listar};

error= (C:\Users\VE\Desktop\REACTjs\APPInversionesTovar\node\node_modules\express\lib\response.js:267:15) at listar (file:///C:/Users/VE/Desktop/REACTjs/APPInversionesTovar/node/controllers/productoController.js:10:13)



Solution 1:[1]

I see here you are using res.send and res.json separately, both will send the response. try using this after the findAll query:

    res.json({msg: "lista de productos", data: listaProductos})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bguiz