I'm currently developing an API using Express.js, implementing routes and controllers.
Within my api.js file, I have the following setup:
const app = express()
app.use('/clients', clients)
Then, in my router/client.js file, I specify the endpoints as follows:
import ClientsController from '../controllers/clients'
clients.get('/', ClientsController.getAll)
clients.get('/:id', ClientsController.getClientData)
clients.get('/getAllProspects', ClientsController.getAllProspects)
The issue arises when I place
clients.get('/:id', ClientsController.getClientData)
before clients.get('/getAllProspects', ClientsController.getAllProspects)
, causing Postman to return results for /:id
instead of /getAllProspects
.
Could someone please shed light on this behavior? Am I missing something crucial here?
Your assistance is greatly appreciated.