Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client On CLI

I have been writing a code for a to do list, this is the node file:

const express=require("express");
const bodyParser=require("body-parser");
const ejs = require('ejs');
const app=express();
app.set("view engine", 'ejs');

app.get("/", function(req, res){
    var today=new Date();
    var currentDay=today.getDay();
    var days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
    var day=""
    if (currentDay===6||currentDay===0){
        res.write("Yay today is a weekend")
        day=days[currentDay];
        console.log(day)
        res.render("list",{kindaDay:day});
        res.send();
        
    }
    else{
        res.write("boo this is a weekday")
        day=days[currentDay];
        res.render("list",{kindaDay:day});
        res.send();
    }
    
})
app.listen(3000, function(){
    console.log("connected to port 3000");
})

And this is the EJS file

<!DOCTYPE html>


<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
    </head>
    <body>
        <h1>It is an amazing day as it is an <%=kindaDay%> </h1>
        <script src="" async defer></script>
    </body>
</html>

The file gives an error which says "Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client" What could possibly be the error?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!