title: Why is my Mongo DB not catching more than 1 of my links?
body: <p>Update on issue.  I now have everything in my mongo db but nothing is showing up on my page. Appears to be something to do with bootbox.  If I click scrape new articles previous dialog disappears and scrape happens successfully.  Upon inspect a new bootbox section appears with an empty h3 tag.</p>
  
  <p><a href="https://github.com/TylerCEdge/tester" rel="nofollow noreferrer">https://github.com/TylerCEdge/tester</a></p>
  
  <p>Currently I get all 20 of the results console logged and all are going to mongo but nothing is showing up on my page.  It's probably a spelling error but I'm having trouble with it.</p>
  
  <pre><code>// Scrape Script
  // =============
  
  // Require axios and cheerio
  var axios = require("axios");
  var cheerio = require("cheerio");
  
  
  var URL = "https://thehackernews.com/search?"
  
  
  function scrape(cb) {
      // First, we grab the body of the html with axios
      axios.get(URL).then(function (response) {
          // Then, we load that into cheerio and save it to $ for a shorthand selector
          var $ = cheerio.load(response.data);
          var articles = [];
  
          // Now, we grab every h2 within an article tag, and do the following:
          $("h2").each(function () {
              // Save an empty dataToAdd object
              var dataToAdd = {};
  
              // Add the text and href of every link, and save them as properties of the dataToAdd object
              dataToAdd.title = $(this)
                  .text()
                  // Removes unwanted characters from the titles
                  .replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' ');
              dataToAdd.link = $(this)
                  .parent().parent().parent().parent()
                  .find("a")
                  .attr("href");
              dataToAdd.img = $(this)
                  .parent().parent().parent()
                  .find("div.home-img").find("div.img-ratio").find("img")
                  .attr("data-src")
              dataToAdd.summary = $(this)
                  .parent()
                  .find("div.home-desc")
                  .text()
                  .replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' ')
  
  
              // console.log(dataToAdd);
              articles.push(dataToAdd);
              // for (i = 0; i = dataToAdd.length; i++) {
              //     articles.push(dataToAdd[i]);
              // }
          });
          cb(articles);
          console.log(articles);
      });
  };
  
  module.exports = scrape;
  
  // Server routes
  
  // Import Scrape
  var scrape = require("../scripts/scrape");
  
  // Import headlines/notes
  var headlinesController = require("../controllers/headlines");
  var notesController = require("../controllers/notes");
  
  module.exports = function (router) {
      router.get("/", function (req, res) {
          res.render("home");
      });
      router.get("/saved", function (req, res) {
          res.render("saved");
      });
  
      router.get("/api/fetch", function (req, res) {
          headlinesController.fetch(function (err, docs) {
              if (!docs || docs.insertedCount === 0) {
                  res.json({
                      message: "no new articles today. Check back tomorrow!"
                  });
              }
              else {
                  res.json({
                      message: "Added " + docs.insertedCount + " new articles!"
                  });
              }
          });
      });
      router.get("/api/headlines", function (req, res) {
          var query = {};
          if (req.query.saved) {
              query = req.query;
          }
          headlinesController.get(query, function (data) {
              res.json(data);
          });
      });
      router.delete("/api/headlines/:id", function (req, res) {
          var query = {};
          query._id = req.params.id;
          headlinesController.delete(query, function (err, data) {
              res.json(data);
          });
      });
      router.get("/api/notes/:headline_id?", function (req, res) {
          var query = {};
          if (req.params.headline_id) {
              query._id = req.params.headline_id;
          }
          notesController.get(query, function (err, data) {
              res.json(data);
          });
      });
      router.delete("/api/notes/:id", function (req, res) {
          var query = {};
          query._id = req.params.id;
          notesController.delete(query, function (err, data) {
              res.json(data);
          });
      });
      router.post("/api/notes", function (req, res) {
          notesController.save(req.body, function (data) {
              res.json(data);
          });
      });
  }
  </code></pre>