Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1K
Vistas
Why is Postman giving me the error 'Cannot POST' for my routes in express app?

I am using Postman to test my function and am using POST to send the request. Every time I send it, I get the error: 'Cannot POST /translate'. I added the code below for my route and function:

 app.post('/translate'), async function(request, response) {
   const translatedText = await translateText(request)
   res.json(translatedText)
}

  async function translateText(request) {
    const text = request.body['text']
    const language = request.body['language']

    let [translations] = await translate.translate(text, language)
    translations = Array.isArray(translations) ? translations : [translations]
    return translations
  }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You've misused the app.post method. First you create the url, as you have done, but then it requires a callback method inside the method parameters.

// remove ) after '/translate'
app.post('/translate', async function(request, response) {
   const translatedText = await translateText(request)
   res.json(translatedText)
});

from the express docs:

Route definition takes the following structure: app.METHOD(PATH, HANDLER) Where:

  • app is an instance of express.
  • METHOD is an HTTP request method, in lowercase.
  • PATH is a path on the server.
  • HANDLER is the function executed when the route is matched.
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda