title: Fetching data from mongodb through nodejs and express to a html page
body: <p>Basically, I want to show particular fields from "employees" collection into a html page. But even after searching a lot on web, I'm unable to do so.</p>
  
  <p>Here is the route part from the server.js file:</p>
  
  <pre><code>app.get('/fetching', function(req, res){
      connection.fetcher(function(data)
          {
              res.render("testing.html",data);
          }
      );
  });
  </code></pre>
  
  <p>Now this is the part from connection.js file:</p>
  
  <pre><code>var fetcher= function(callback) {
      var mongodb = require('mongodb');
      var MongoClient = mongodb.MongoClient;
  
      var url = 'mongodb://localhost:27017/HippoFeedo';
  
      MongoClient.connect(url, function (err, db) {
          if (err) {
  
              console.log('Unable to connect to the mongoDB server. Error:', err);
          }
  
          else {
              console.log('Connection established to', url);
  
              // Get the documents collection
              var collection = db.collection('employees');
  
              collection.find({},function (err, result) {
                  if (err) {
                      console.log(err);
                  } else {
  
                      console.log(result);
                      callback(result);
                  }
  
              });
          }
      });
  </code></pre>
  
  <p>Now, findOne is working fine and returning the value to <code>server.js</code> file perfectly. But I need to use "find", so how to send the complete array to the <code>server.js</code> through callback?</p>
  
  <p>And moreover, I need to send that retrieved data from <code>server.js</code> to a HTML file called <code>testing.html</code> through rendering and display it through angular js. Please explain a simple way to do so.</p>
  
  <p>EDIT:
  I got to know how to work with "find", I just used "toArray" alongwith "find" in function. And now, I'm able to return the value to server.js through call back. But the other question is still unsolved: How do I pass those values to the html page?</p>