Typeerror: app.use() requires a middleware Function

Asked

Viewed 881 times

0

Index

const express = require("express");
    const bodyParser = require("body-parser");
    const router = require("./config/routes");

    const app = express();

    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: true }));

    app.use(router);

    app.use(4000);

controller

 const { Time } = require("../models/index");

module.exports = {
  async create(req, res) {
    const time = await Time.create(req.body);
    return res.json(time);
  }
};

model

    "use strict";

module.exports = (sequelize, DataTypes) => {
  const Time = sequelize.define(
    "Time",
    {
      name: DataTypes.STRING
    },
    {}
  );
  return Time;
};

Good evening guys, I’m with this error Typeerror: app.use() requires a middleware Function, as always but it seemed that, someone can help me, grateful.

  • 1

    Basically the app.use is a function that expects another function as parameter, middleware. Therefore, you cannot do app.use(4000);.

  • , puts that was lasca kkk thanks.

  • 4000 was supposed to be the door? Check if you didn’t want to call the Listen method.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.