title: How do I seed mongodb with data from an external API?
body: <p>I'm trying to learn NodeJS. I'm using mongoose &amp; mLab. I'm new to every one of these technologies.</p>
  
  <p>My model at the moment looks like this. I will add a few things to the schema later. </p>
  
  <pre><code>const mongoose = require("mongoose");
  const fetchData = require("../seed");
  
  const schema = mongoose.Schema;
  
  const dataSchema = new Schema({});
  
  module.exports = recallData = mongoose.model("recalls", dataSchema);
  </code></pre>
  
  <p>I also made a seed file for fetching data..</p>
  
  <pre><code>const Recall = require("./models/Recall");
  
   module.exports = function getData(req, res) {
    const urls = [url1, url2, url3];
  
    urls.map(url =&gt; {
      fetch(url)
        .then(res =&gt; res.json())
        .then(data =&gt;
          data.results.map(recalls =&gt; {
            let recs = new Recall(recalls);
            recs.save;
          })
        );
    });
  }
  </code></pre>
  
  <p>my question is how do I make the fetch run and populate the database? Is there a command or a mongoose function that will do that?
  I know that I'm basically trying to emulate Rails with a seed file. Maybe it's not the way to do it in Node. Any help is super appreciated.</p>