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

141
Views
Backend code sending response to client side but not showing output of other lines in console log

I am running a backend code written on Node.js for my application. When I host my backend on a port, I am able to get the API response to my client side but outputs that should be displayed in console log(in Node) are not being displayed. I am assuming that when I run this code on my localhost port the entire code should be executed thus resulting in console log outputs (eg: "DB connected" should be displayed in console log). But this is not happening. Only the post request console log O/P is being displayed(i.e "response sent"). Why is this happening?

Note: The post request O/P is displayed only when I post to the backend. It is not being displayed by default which is the expected behaviour.

import express from "express";
import mongoose from "mongoose";
import cors from "cors";
import DB from "./env";
const app = express();
// DB connection

mongoose.connect(DB,{})
.then(() => {console.log("DB connected")})
.catch((error) => {error});
//middlewares

app.use(express.json({}));
app.use(cors({
    origin:["http://localhost:3000"],
}));

//the actual backend response from server

app.post("/" , (req,res) => {
   console.log("response sent");
   //console.log(req.body.email);
   //console.log(req.body);
   res.end("backnd working");
})

//listen on port 8000

app.listen(8000);
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!