title: NodeJS crashed with three dots
body: <p>I have a really weird problem with my nodejs project. The project is an online shop with express and handlebar and it has a mongo database connected. In the router section I have this code:</p>
  <pre><code>router.get('/item/:item', function (req, res, next) {
  var actItem = {};
  Item.find().findOne({ '_id': req.params.item }, function (err, item) {
      actItem.name = item.item_name;
      actItem.price = item.price;
      actItem.description = item.description;
      actItem.imageLink = item.imageLink;
  
  });
  res.render('pages/shop/item-view', { title: 'Express', item: actItem });
  </code></pre>
  <p>});</p>
  <p>It looks for the item ID in the URL on the database and it returns the view passing the data to be displayed. It works just fine but then in the view i have this code:</p>
  <pre><code>&lt;div id=&quot;carouselExampleControls&quot; class=&quot;carousel slide&quot; data-ride=&quot;carousel&quot;&gt;
  &lt;div class=&quot;carousel-inner&quot;&gt;
      &lt;div class=&quot;carousel-item active&quot;&gt;
          &lt;img class=&quot;d-block w-100&quot; src=&quot;{{item.imageLink}}&quot; alt=&quot;First slide&quot;&gt;
      &lt;/div&gt;
      &lt;div class=&quot;carousel-item&quot;&gt;
          &lt;img class=&quot;d-block w-100&quot; src=&quot;&quot; alt=&quot;Second slide&quot;&gt;
      &lt;/div&gt;
      &lt;div class=&quot;carousel-item&quot;&gt;
          &lt;img class=&quot;d-block w-100&quot; src=&quot;&quot; alt=&quot;Third slide&quot;&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;a class=&quot;carousel-control-prev&quot; href=&quot;#carouselExampleControls&quot; role=&quot;button&quot; data-slide=&quot;prev&quot;&gt;
      &lt;span class=&quot;carousel-control-prev-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;
      &lt;span class=&quot;sr-only&quot;&gt;Previous&lt;/span&gt;
  &lt;/a&gt;
  &lt;a class=&quot;carousel-control-next&quot; href=&quot;#carouselExampleControls&quot; role=&quot;button&quot; data-slide=&quot;next&quot;&gt;
      &lt;span class=&quot;carousel-control-next-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;
      &lt;span class=&quot;sr-only&quot;&gt;Next&lt;/span&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>And it works just fine too! But here comes the problem. Whenever I add three dots in any src attribute, it crashed. Even weirder is that it crashed even if I edit the html document after render in chrome and add them, like this:</p>
  <pre><code>&lt;img class=&quot;d-block w-100&quot; src=&quot;...&quot; alt=&quot;Second slide&quot;&gt;
  </code></pre>
  <p>The error of the crash is this:</p>
  <pre><code>actItem.name = item.item_name;
                      ^
  TypeError: Cannot read property 'item_name' of undefined
  </code></pre>
  <p>Any idea on how to fix this and why it happens?</p>
  <h1>SOLUTION</h1>
  <p>I managed to solve this problem by checking the item before doing anything.</p>
  <pre><code>if (item) {
    actItem.name = item.item_name;
    actItem.price = item.price;
    actItem.description = item.description;
    actItem.imageLink = item.imageLink;
  }
  </code></pre>
  <p>It happens because when I use ... the browser makes the request /item/... to get the image, then the value of req.params.item becomes ... and in database there is no entry with _id = ... . So the item value well be undefined</p>