title: console.log inside loopback Rest API
body: <p>I'm working on a react app that has a Loopback Rest API. I'm trying to create a post method that takes an array of articles as an argument. The functions are created but they doesn't work. Unfortunately i don't know how to debug and id'd like to see wether my call even enters the function and if so how the object / array looks like.</p>
  <p>in remote-cart.js</p>
  <pre><code>Cart.addArticles = (id, articles, cb) =&gt; {
  
  console.log(articles);
  
  articles.map(article =&gt; {
    let error;
    if (article.qty &lt;= 0) {
      error = new Error('Quantity can\'t be negative or null!');
      error.statusCode = 400;
      error.code = 'cant_be_negative_or_null'.toUpperCase();
      return cb(error);
    }
    Promise
      .all([Cart.findById(id), Article.findById(article.articleId)])
      .then((all) =&gt; {
        const article = all[1];
        if (!article) {
          error = new Error('Article doesn\'t exist');
          error.statusCode = 400;
          error.code = 'Article_doesnt_exist'.toUpperCase();
          cb(error);
        }
        const cart = all[0];
        let articles = [];
        if (cart.articles) {
          // articles exist
          articles = JSON.parse(cart.articles);
          const articleIndex =  _findIndex(articles, (item) =&gt;
            item.articleId === article.id);
          if (articles[articleIndex]) {
            const oldQty = articles[articleIndex].qty ?
              articles[articleIndex].qty : 0;
            const newQty = oldQty + article.qty;
            articles[articleIndex].qty = newQty;
            
            articles[articleIndex].total = calculateSubTotal(article, newQty);
          } else {
            articles.push({
              articleId: article.articleId,
              qty: article.qty,
              total: calculateSubTotal(article, article.qty),
            });
          }
        } else {
          // articles doesn't exit
          articles.push({
            articleId: article.articleId,
            qty: article.qty,
            total: calculateSubTotal(article, article.qty),
          });
        }
        cart.articles = JSON.stringify(articles);
        cart.total = calculateTotal(articles);
        return cart;
      })
      .then(cart =&gt; {
        cart.save({}, (err, data) =&gt; {
          if (err) {
            return err;
          }
          cb(null, cart);
        });
      })
      .catch(err =&gt; cb(err));
  });
  };
  
  
  Cart.remoteMethod('addArticles', {
  description: [
    'Add or increase the quantity of any Article in cart',
    ' model instance by {{id}} from the data source',
  ],
  accepts: [{
    arg: 'id',
    type: 'number',
    required: true,
  }, {
    arg: 'articles',
    type: 'array',
    required: true,
  }],
  returns: [
    {arg: 'id', type: 'number', root: true},
    {arg: 'clientId', type: 'number', root: true},
    {arg: 'articles', type: 'string', root: true},
    {arg: 'total', type: 'number', root: true},
    {arg: 'lines', type: 'array', root: true},
    {arg: 'lineCount', type: 'number', root: true},
    {arg: 'created_at', type: 'Date', root: true},
    {arg: 'updated_at', type: 'Date', root: true},
  ],
  http: {path: '/:id/add-articles', verb: 'post'},
  });
  </code></pre>