Closed BuruY closed 6 years ago
Hi @BuruY, thank you for creating this issue. For more complex scenarios like this one you should use the middleware.
Best, Simon
Thanks for the lightning fast response.
I have following code as middleware:
middleware: {
'/rest/xxx/#xxx/GET/mock'(serverOptions, requestOptions) {
var name = requestOptions.req.query.Name;
console.log('TEST' + name);
if (name === 'noresults') {
requestOptions.res.statusCode = 204;
return null;
}
return 'success';
}
}
I do not seem to do it right, I have found no query examples in pointed documentation. Perhaps you can point me towards correct direction?
Thanks!
Got it to work, documentation is not clear on this one but you need to have a response.txt that states: middleware
Hi @smollweide, Thank you for maintaining this package!
I have following succes.json:
Here I would like when Name = noresults, it returns a 204 HTTP status code. But it seems (since this logic is applied from the success.json) always returning a statusCode 200.
When calling the file error-204 directly with response.txt it does show correct statusCode, but this makes it no longer dynamic (input based).
Is there another way node-mock-server supports my use case?