title: How to use service layer in node js
body: <p>I am new for Node js. I have use express and sequelize for my application.</p>
  
  <p>This is my router function.</p>
  
  <pre><code>router.post('/add-merchant', [
      check('name').not().isEmpty(),
      check('city').not().isEmpty(),
      check('state').not().isEmpty(),
      check('country').not().isEmpty(),
  ], (req, res, next) =&gt; {
      try {
          const errors = validationResult(req);
  
          if (!errors.isEmpty()) {
              return res.json({ errors: errors.array()});
          }
  
          var merchant = merchantService.addMerchant(req);
          return res.json(merchant)
      } catch (error) {
          return res.json({"status": "error", "message": error.message})
      }
  });
  </code></pre>
  
  <p>I have created file called merchantService.js</p>
  
  <p>I have added code for inserting data in merchantService.js and tried like this</p>
  
  <pre><code>var merchant = merchantService.addMerchant(req);
  </code></pre>
  
  <p>But I cannot get any data from merchant service. Here is my merchant service code </p>
  
  <p>var models = require("../models");</p>
  
  <pre><code>var merchantService = {
      addMerchant: (req) =&gt; {
          models.merchants.create(req.body).then((merchant) =&gt; {
              return merchant.dataValues
          });
      }
  }
  
  module.exports = merchantService;
  </code></pre>
  
  <p>I cannot find the issue. Please help anyone to solve this issue.</p>
  
  <p>Thanks in advance</p>