title: Connect mongodb using mongoose and nodejs on docker compose
body: <p>I'm trying to connect mongodb with a React app using mongoose and docker compose in order to save twitter api credentials and then view twitter trends from twitter api and I get this error:</p>
  <p>GET http://localhost:3000/api/trends?woeid=1 500 (Internal Server Error)</p>
  <p>My file structure is the following:</p>
  <pre><code>twitter-trends-api-main-master
  frontend
  backend
  </code></pre>
  <p>I use mongoose in schema.js in the backend:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>const mongoose = require("mongoose");
  
  var nameSchema = new mongoose.Schema({
      PORT: { type: Number, required: true },
      TWITTER_CONSUMER_API_KEY: { type: String, required: true },
      TWITTER_CONSUMER_API_SECRET: { type: String, required: true },
      TWITTER_ACCESS_TOKEN: { type: String, required: true },
      TWITTER_ACCESS_SECRET: { type: String, required: true }
  });
  
  module.exports = mongoose.model("credentials", nameSchema);</code></pre>
  </div>
  </div>
  </p>
  <p>for connecting to the twitter api I use:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>const client = new Twitter({
    consumer_key: function data() {schema.findOne({}).exec(function (err, someValue) {return(someValue[0].TWITTER_CONSUMER_API_KEY);});},
    consumer_secret: process.env.TWITTER_CONSUMER_API_SECRET,
    access_token_key: process.env.TWITTER_ACCESS_TOKEN,
    access_token_secret: process.env.TWITTER_ACCESS_SECRET,
  })</code></pre>
  </div>
  </div>
  </p>
  <p>Using the script consumer_key is not defined so I can't return data at consumer_key.</p>