title: throw new TypeError('Router.use()requires a middleware function but got a ' + gettype(fn))v
body: <p>Im getting the error:</p>
  
  <p>throw new TypeError('Router.use()requires a middleware function but got a ' + gettype(fn))v</p>
  
  <p>I'm fairly new and not sure what is going on! Any help would be greatly appreciated and let me know if there is any other information that might be helpful. Thanks so much ahead of time!!!!!!!</p>
  
  <p>Here is my app.js: </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-js lang-js prettyprint-override"><code>const express = require('express');
  const app = express(); // object with methods; One method is router; express creates a server; app allows us to access the server; app.listen hooks up our server;
  const morgan = require('morgan'); //app.use(...) morgan says console.log(wht app.use does);
  const { db, Review, Toilet, User } = require('./server/db/index');
  
  // Logger:
  app.use(morgan('dev')); // implies '/' ('/', morgan('dev'));
  
  //Body parser:
  app.use(express.urlencoded({ extended: false }));
  app.use(express.json());
  
  // public:
  app.use(express.static(__dirname + '/public'));
  
  // Backend Routing:
  app.use('/api', require('./server/api/index'));
  
  // Setting up server
  const PORT = process.env.PORT || 8880;
  
  const syncDb = () =&gt; db.sync();
  
  const startListening = () =&gt; {
    app.listen(PORT, function() {
      console.log(
        ` ***** I'm leisurely listening on pleasant port of ${PORT} *****`
      );
    });
  };
  
  async function bootApp() {
    await syncDb();
    await startListening();
  }
  
  bootApp();</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my sever/api/index.js:</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-js lang-js prettyprint-override"><code>const router = require('express').Router();
  
  router.use('/toilets', require('./toiletRoutes'));
  router.use('/users', require('./userRoutes'));
  router.use('/reviews', require('./reviewRoutes'));
  
  module.exports = router;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my sever/db/api/toiletRoutes.js:</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-js lang-js prettyprint-override"><code>const express = require('express');
  const router = express.Router();
  const { Toilet, User, Review } = require('../db/index');
  
  // Get all toilets
  router.get('/', async function(req, res, next) {
    console.log('in get all toilets');
    try {
      const allToilet = await Toilet.findAll();
      res.status(200).send(allToilet);
    } catch (error) {
      next(error);
    }
  });
  
  module.exports = router;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my package.json:</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-js lang-js prettyprint-override"><code>{
    "name": "newflush",
    "version": "1.0.0",
    "description": "",
    "main": "app.js",
    "engines": {
      "npm": "6.4.1",
      "node": "10.7.0"
    },
    "scripts": {
      "start": "webpack -w &amp; node app.js",
      "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
      "axios": "^0.18.0",
      "babel": "^6.23.0",
      "babel-core": "^6.26.3",
      "babel-loader": "^7.1.5",
      "babel-polyfill": "^6.26.0",
      "babel-preset-env": "^1.7.0",
      "babel-preset-react": "^6.24.1",
      "babel-upgrade": "0.0.23",
      "express": "^4.16.3",
      "google-map-react": "^1.1.2",
      "morgan": "^1.9.1",
      "path": "^0.12.7",
      "pg": "^7.8.1",
      "pg-hstore": "^2.3.2",
      "react": "^16.5.2",
      "react-burger-menu": "^2.5.4",
      "react-dom": "^16.5.2",
      "react-geocode": "^0.1.2",
      "react-google-maps": "^9.4.5",
      "react-redux": "^5.0.7",
      "react-router": "^4.3.1",
      "react-router-dom": "^4.3.1",
      "redux": "^4.0.0",
      "redux-thunk": "^2.3.0",
      "sequelize": "^4.43.0",
      "webpack": "^4.20.2",
      "webpack-cli": "^3.1.2"
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="https://i.stack.imgur.com/mwrD9.png" rel="nofollow noreferrer">Here is my server file tree</a></p>