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

129
Views
How can i solve it index.js:1 Error: Network Error *at createError (createError.js:16) *at XMLHttpRequest.handleError (xhr.js:117

*This is my code and I had this error when I try to connect nodejs with react use nodemailer, can you help me to solve it, please? * index.js:1 Error: Network Error at createError (createError.js:16) at XMLHttpRequest.handleError (xhr.js:117)

const express = require("express");
const app = express();
require("dotenv").config();

const bodyParser = require("body-parser");
const cors = require("cors");
const nodemailer = require("nodemailer");

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

app.use(cors());

app.post("/send_mail", cors(), async (req, res) => {
  let { text } = req.body;
  const transport = nodemailer.createTransport({
    host: process.env.MAIL_HOST,
    port: process.env.MAIL_PORT,
    auth: {
      user: process.env.MAIL_USER,
      pass: process.env.MAIL_PASS,
    },
  });

  await transport.sendMail({
    from: process.env.MAIL_FROM,
    to: "test@test.com",
    subject: "test email",
    html: `<div className="email" style="
        border: 1px solid black;
        padding: 20px;
        font-family: sans-serif;
        line-height: 2;
        font-size: 20px; 
        ">
        <h2>Here is your email!</h2>
        <p>${text}</p>
    
        <p>All the best, Ala</p>
         </div>
    `,
  });
});

app.listen(
  (process.env.PORT || 4000,
  () => {
    console.log("Server is listening on port 4000");
  })
);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It seems that something's wrong with your app.listen definition:

Why do you need ``` at the eof?

app.listen(
  process.env.PORT || 4000,
  () => {
    console.log("Server is listening on port 4000");
  });
about 4 years ago · Juan Pablo Isaza Report
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!