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.
Basically the
app.use
is a function that expects another function as parameter, middleware. Therefore, you cannot doapp.use(4000);
.– Samir Braga
, puts that was lasca kkk thanks.
– Pedro Henrique
4000 was supposed to be the door? Check if you didn’t want to call the Listen method.
– Daniel Mendes