mock-config-server
mock-config-server copied to clipboard
Requests with url params can overwrite similar requests without params
Now such similar requests have the following problem. If a request with a parameter comes before a request without parameter, then in response to the request without parameters the response for the request with the parameter is sent.
[
{
path: '/users/:userId',
method: 'get',
routes: [{ data: '/users/:userId data' }]
},
{
path: '/users/list',
method: 'get',
routes: [{ data: '/users/list data' }]
}
]
// GET /users/1 -> '/users/:userId data' - correct
// GET /users/list -> '/users/:userId data' - wrong response
If it's the other way around, then everything works as it should.
[
{
path: '/users/list',
method: 'get',
routes: [{ data: '/users/list data' }]
},
{
path: '/users/:userId',
method: 'get',
routes: [{ data: '/users/:userId data' }]
}
]
// GET /users/1 -> '/users/:userId data' - correct
// GET /users/list -> '/users/list data' - correct
I may be wrong, but that's how routers work, it's called route priority - https://stackoverflow.com/questions/32603818/order-of-router-precedence-in-express-js
@zeroqs yes you are right but we can do it instead of the users and improve their development experience