[Vuejs]-Connecting Vue.js Frontend -> through Express, Node.js, Sequelize (API) endpoints. (PostgreSQL)

0๐Ÿ‘

โœ…

I managed to sort it out.

You controller section should include.

async showAll (req, res) {
    try {
      const products = await Product.findAll({
        where: {},
        include: [
          {
            model: ParentName
          }
        ]        
      })        
      res.send(products)      
    } catch (err) {
      res.status(500).send({
        error: 'An Error has occured trying to retrieve Products'
      })
    }
  }

Your .vue component Script section

    async mounted () {this.products = (await ProductsService.showAll()).data
  }

And calling it in the Template Component within vue becomes easy

{{ props.item.Principal.name }}

Leave a comment