title: How to loop data imported from SQLite database
body: <p>I am building an <strong>Express</strong> app ,and i am using <strong>SQLite</strong> database, I managed to fetch the data from the database, but I want to display it in the interface ,So i did this :</p>
  <p><strong>index.js</strong></p>
  <pre class="lang-js prettyprint-override"><code>/* GET THE LIST OF HOMES*/
  router.get('/:homes-list', (req,res) =&gt; {
    db.all( &quot;SELECT * FROM home WHERE owner_id = ?&quot;,[
      req.user.id
    ],
    function(err, rows) {
      if (err) { return next(err); }
      
      const home = rows.map(function(row) {
        return {
          location: row.location,
          for: row.for,
        }
          
      });
      res.locals.homes = home; 
      console.log(res.locals.homes)
      res.redirect(&quot;/:homes-list&quot;, {home: res.locals.homes})
    });
  });
  </code></pre>
  <p>Then I tried to display it for the user interface using <strong>EJS:</strong></p>
  <p><strong>index.ejs</strong></p>
  <pre class="lang-html prettyprint-override"><code>
                      &lt;form action=&quot;/:homes-list&quot; method=&quot;get&quot;&gt;
                          &lt;table&gt;
                              &lt;tbody&gt;
                          &lt;% home.forEach(function(homes) { %&gt;
                              &lt;tr&gt;
                                &lt;td&gt;&lt;%= homes.location %&gt;&lt;/td&gt;
                                &lt;td&gt;&lt;%= homes.for %&gt;&lt;/td&gt; 
                              &lt;/tr&gt;
                            &lt;% }); %&gt; 
                          &lt;/tbody&gt;
                          &lt;/table&gt;
                      &lt;/form&gt;
  </code></pre>
  <p>After i did all that i had an <strong>error:</strong></p>
  <p><strong>Error</strong></p>
  <pre><code>/media/onour/Desing/Des/test/roshan/views/index.ejs:45 43| &lt;table&gt; 44| &lt;tbody&gt; &gt;&gt; 45| &lt;% home.forEach(function(homes) { %&gt; 46| &lt;tr&gt; 47| &lt;td&gt;&lt;%= homes.location %&gt;&lt;/td&gt; 48| &lt;td&gt;&lt;%= homes.for %&gt;&lt;/td&gt; home is not defined
  ReferenceError: /media/onour/Desing/Des/test/roshan/views/index.ejs:45
      43|                         &lt;table&gt;
      44|                             &lt;tbody&gt;
   &gt;&gt; 45|                         &lt;% home.forEach(function(homes) { %&gt;
      46|                             &lt;tr&gt;
      47|                               &lt;td&gt;&lt;%= homes.location %&gt;&lt;/td&gt;
      48|                               &lt;td&gt;&lt;%= homes.for %&gt;&lt;/td&gt; 
  
  home is not defined
      at eval (eval at compile (/media/onour/Desing/Des/test/roshan/node_modules/ejs/lib/ejs.js:633:12), &lt;anonymous&gt;:11:8)
      at returnedFn (/media/onour/Desing/Des/test/roshan/node_modules/ejs/lib/ejs.js:668:17)
      at tryHandleCache (/media/onour/Desing/Des/test/roshan/node_modules/ejs/lib/ejs.js:254:36)
      at View.exports.renderFile [as engine] (/media/onour/Desing/Des/test/roshan/node_modules/ejs/lib/ejs.js:485:10)
      at View.render (/media/onour/Desing/Des/test/roshan/node_modules/express/lib/view.js:135:8)
      at tryRender (/media/onour/Desing/Des/test/roshan/node_modules/express/lib/application.js:640:10)
      at Function.render (/media/onour/Desing/Des/test/roshan/node_modules/express/lib/application.js:592:3)
      at ServerResponse.render (/media/onour/Desing/Des/test/roshan/node_modules/express/lib/response.js:1008:7)
      at /media/onour/Desing/Des/test/roshan/routes/index.js:22:7
      at Layer.handle [as handle_request] (/media/onour/Desing/Des/test/roshan/node_modules/express/lib/router/layer.js:95:5)
  </code></pre>
  <p>and i didn't understand the error, so i didn't know what to do.</p>