That commit replaced the deprecated req.param(key) function in Express v3, which would get a parameter value from the route parameters, request body, or querystring. It was replaced with req.query, which does not retrieve values from the route parameters (req.params). So mocked routes that used route params (e.g. v2/position/:lang/:id) would not return the file designated by the route parameter value (e.g. v2/id376217.position.json)
This PR uses a getRequestParam utility function to retrieve a switch value from the body, route params, querystring, or header. It fixes #91
A recent change to how a switch value was accessed from a request introduced a regression bug: https://github.com/gstroup/apimocker/commit/5df065d0be7600a895e3a555fe7e6c918f9b8c44
That commit replaced the deprecated
req.param(key)
function in Express v3, which would get a parameter value from the route parameters, request body, or querystring. It was replaced withreq.query
, which does not retrieve values from the route parameters (req.params
). So mocked routes that used route params (e.g.v2/position/:lang/:id
) would not return the file designated by the route parameter value (e.g.v2/id376217.position.json
)This PR uses a
getRequestParam
utility function to retrieve a switch value from the body, route params, querystring, or header. It fixes #91