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

1K
Views
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 answers
Answer question

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 Report
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!