request-promise doesn't seem to apply the given options.transform function to the response object attached to a StatusCodeError.
I'd expect that transform to be applied, given the relation implied by "Rejected promises and the simple option" example. In this case, the standard request library would have parsed the request body before it was filtered by status code. The response at this point is not an error with the request so I see no gain in not parsing the response.
I realise this would be a breaking change, so was wondering if it would be of interest to pass an additional option to enable this behaviour?
For example, something along the lines of
} else if (self._rp_options.simple && !(/^2/.test('' + response.statusCode))) {
var statusCodeError;
if (self._rp_options.transformError && isFunction(self._rp_options.transform)) {
try {
body = self._rp_options.transform(body, response, self._rp_options.resolveWithFullResponse);
} catch (e) {
return self._rp_reject(e);
}
}
self._rp_reject(assign(new errors.StatusCodeError(response.statusCode, body), {
error: body,
options: self._rp_options,
response: response
});
Thanks
request-promisedoesn't seem to apply the givenoptions.transformfunction to theresponseobject attached to aStatusCodeError.I'd expect that transform to be applied, given the relation implied by "Rejected promises and the simple option" example. In this case, the standard
requestlibrary would have parsed the request body before it was filtered by status code. The response at this point is not an error with the request so I see no gain in not parsing the response.I realise this would be a breaking change, so was wondering if it would be of interest to pass an additional option to enable this behaviour?
For example, something along the lines of
Thanks