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

215
Views
Express PUT route, with tedious connection to Azure database

I am trying to make a PUT request, updating the users e-mail. I am testing the endpoint with Postman.

I am pretty sure the mistake is in line 7, but I can't seem to get it working. My final goal, is updating the user email to whatever is put into a input field in HTML.

Is somebody able to spot what I am missing?

/src/routes/userRoutes.js

const express = require("express");
var Connection = require("tedious").Connection;
const sql = require("mssql");
const config = require("../../config.json");
var connection = new Connection(config);
const router = express.Router();

router.post("/updateUser", (req, res) => {
  sql.connect(config, function (err) {
    if (err) console.log(err);
    // create Request object
    var request = new sql.Request();
    // query to the database and get the records
    const email = req.body.email;
    request.query(
      `update dbo.[user]
      set User_Email = '${email}'
      where User_ID = 6`,
      function (err, recordset) {
        if (err) {
          console.log(err);
        } else {
          console.log(`User has been updated!`);
          res.json("Updated user");
        }
      }
    );
  });
});

app.js

const express = require('express')
const app = express();
const PORT = 3000;
const userRoutes = require('./src/routes/userRoutes')
const path = require('path')

app.use(express.static('./src/views'));
app.use(express.json())


app.use('/', userRoutes)
app.use('/createUser', userRoutes)
app.use('/updateUser', userRoutes)
app.use('/deleteUser', userRoutes)

//app.get('/updateProduct', (req,res) => {
//    res.render(path.join(__dirname, '/src/views/updateProduct.html'))
//})



app.listen(PORT, () => {
    console.log(`Server is listening on ${PORT}`);
})

POSTMAN output

Cannot PUT /updateUser
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!