Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
i run this code but showing router.use() requires a middleware function but got a ' + gettype(fn) this error

//jshint esversion:6
const express = require("express");
const bodyParser = require("body-parser");

const app = express();
    app.use("view-engine", "ejs");
    app.get("/", function(req, res){
var today = new Date();
var currentDay = today.getDay();
var day = "";
if (currentDay === 6 || currentDay === 0) {
  day = "Weekend";
}else {
  day = "weekday";
}
res.render("list" , {kindofDay:  day});
});

app.listen(3000, function(){
  console.log("Server started on port 3000");
});

i can't see where i have gone wrong. Can anybody see? whenever i run this app.js showing that router.use() requires a middleware function but got a ' + gettype(fn) this error.

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>To Do List</title>
  </head>
  <body>
    <h1>It's a <%= kindofDay %></h1>
  </body>
  </html>

This is my list.ejs file..

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

app.use([path,] callback [, callback...]) -> This code is what you use when you want a specific callback function to run at a specific path. This is called a middleware.

app.set(name, value) -> This code is what you use when you want assign a value to some variable. You can uyse any name, but certain names can be used to configure the behavior of the server. One of these names is view engine (notice there is no hyphen). It will set the template engine to use.

If your aim is to set ejs as your template engine, just do app.set("view engine", "ejs");

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda