0

I have a very simple express API:

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('in root!')
})

app.get('/hello', (req, res) => {
  res.send('in hello! req.query.id is ' + req.query.id)
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})

Hitting it with CURLs:

curl http://localhost:3000/hello

Result is:

in hello! req.query.id is undefined

Which is correct. Now I run:

curl http://localhost:3000/hello?id=123

Hey presto, I get:

no matches found: http://localhost:3000/hello?id=123

According to the answer here it really should be as simple as adding "?id=123" to the URL, but somehow I've made a mistake somewhere because now the endpoint is not matched...

Im using express v4.17.1

EDIT Can ANYONE else reproduce this problem?

Mark
  • 4,428
  • 14
  • 60
  • 116

0 Answers0