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

1K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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