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

330
Visualizações
Getting error 404 for put request (using express and node js)

I'm more or less new to web development and I've had trouble getting a PUT request to go through. We've set up a database and succeeded in getting GET and POST requests work but we keep getting a 404 error with trying to send a PUT request.

router.put('/edit-beverage/:id', (req, res) => {

    console.log(`Updating beverage on id ${data.params.id}:`);
    let data = req.body;

    query1 = `UPDATE Beverage `
    query1 += `SET name = '${data.nameInput}', abv = ${data.abvInput}, breweryID = ${data.breweryID_FK}, categoryID = ${data.categoryID_FK} `
    query1 += `WHERE beverageID = ${data.params.id};`

    db.pool.query(query1, (err, rows, fields) => {
        res.redirect('/');
    });
});

Here's what we have on another page.

let express = require('express');   // We are using the express library for the web server
let app = express();            // We need to instantiate an express object to interact with the server in our code
PORT = process.env.PORT || 3000;;                 // Set a port number at the top so it's easy to change in the future
app.use(express.json());
app.use(express.urlencoded({extended: true}));


// Cors should allow access from extrernal addresses.
var cors = require('cors')
app.use(cors())

// Database
const db = require('./database/db-connector')

/*
    ROUTES
*/
// create new Router instance for api routes
// mount the router on the app
app.use('/', require('./routes'));
module.exports = app;

let router = require('express').Router();

And this is what I try to send on Postman. As far as I can tell, the endpoint is the same as what's on the file

Would anyone be able to tell me what's going on? I'm confused as to why the server isn't recognizing the request as a proper path.

about 4 years ago · Juan Pablo Isaza
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