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

237
Views
No se puede asegurar a Postgres SQL a través de Postman

Estoy tratando de insertar una nueva película en Postgres SQL a través del cartero, pero no puedo. ¿Hay alguien que pueda ayudarme?

Aquí están las capturas del cartero: ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí Cuando publico la nueva película, siempre dice: "Cannot POST /api/movies".

Aquí está mi código:

 const db = require('./dbconfig'); // Get all movies const getAllMovies = (req, res) => { db.query('SELECT * FROM movies', (err, result) => { if (err) console.error(err); else res.json(result.rows) }) } // Get movie by id const getMovieById = (req, res) => { const query = { text: 'SELECT * FROM movies WHERE id = $1', values: [req.params.id], } db.query(query, (err, result) => { if (err) { return console.error('Error executing query', err.stack) } else { if (result.rows.length > 0) res.json(result.rows); else res.status(404).end(); } }) } // Add new movie const addMovie = (req, res) => { // Extract movie from the request body const newMovie = req.body; const query = { text: 'INSERT INTO movies (title, director, year) VALUES ($1, $2, $3)', values: [newMovie.title, newMovie.director, newMovie.year], } db.query(query, (err, res) => { if (err) { return console.error('Error executing query', err.stack) } }) res.json(newMovie); } res.status(204).end(); } module.exports = { getAllMovies: getAllMovies, getMovieById: getMovieById, addMovie: addMovie, }

// índice.js

 const express = require('express'); const bodyParser = require('body-parser'); const query = require('./db/movies'); const app = express(); app.use(bodyParser.json()); const port = 3000; app.get("/api/movies", query.getAllMovies); app.get("/api/movies/:id", query.getMovieById); app.post("/api/movies", query.addMovie); app.listen(port, () => {{} console.log(`Server is running on port ${port}.`); });
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!