request-promise
semver
>=4.0.0postconditions16functions7last verified2026-04-20coverage score73%Postconditions — what we check
- default · http-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and options.simple is true (default)Throws
StatusCodeError with statusCode, error (response body), options, and response propertiesRequired handlingCaller MUST catch StatusCodeError and check err.statusCode to handle HTTP errors. Default behavior (simple: true) throws on non-2xx status codes.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - default · network-failureerrorWhennetwork error, DNS failure, timeout, or connection refusedThrows
RequestError with cause (underlying error), error, options, and response propertiesRequired handlingCaller MUST catch RequestError to handle network failures. Check err.cause for underlying error details (ECONNREFUSED, ENOTFOUND, ETIMEDOUT, etc.).costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - default · transform-function-errorerrorWhenoptions.transform() function is configured and throws an error during executionThrows
TransformError with cause (the error thrown by the transform function), error, options, and response properties. TransformError.name === 'TransformError'.Required handlingCallers using options.transform MUST also handle TransformError in addition to StatusCodeError and RequestError. A catch block catching only StatusCodeError will silently swallow transform failures, causing the promise to never settle. TransformError.cause contains the original error from the transform function.costmediumin prodsilent failureusers seelost datavisibilitysilent - get · http-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and options.simple is true (default)Throws
StatusCodeError with statusCode, error, options, and response propertiesRequired handlingCaller MUST catch StatusCodeError when using rp.get(). Same behavior as calling rp() directly — non-2xx responses reject unless simple: false is set.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - get · network-failureerrorWhennetwork error, DNS failure, timeout, or connection refusedThrows
RequestError wrapping the underlying Node.js errorRequired handlingCaller MUST catch RequestError for network-level failures. Check err.cause for the underlying error (ECONNREFUSED, ENOTFOUND, etc.).costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - post · http-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and options.simple is true (default)Throws
StatusCodeError with statusCode, error, options, and response propertiesRequired handlingCaller MUST catch StatusCodeError when using rp.post().costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - post · network-failureerrorWhennetwork error, DNS failure, timeout, or connection refusedThrows
RequestError wrapping the underlying Node.js errorRequired handlingCaller MUST catch RequestError for network failures when using rp.post().costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - put · http-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and options.simple is true (default)Throws
StatusCodeError with statusCode, error, options, and response propertiesRequired handlingCaller MUST catch StatusCodeError when using rp.put(). PUT requests to missing or unauthorized resources (404, 403) will reject by default.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - put · network-failureerrorWhennetwork error, DNS failure, timeout, or connection refusedThrows
RequestError wrapping the underlying Node.js errorRequired handlingCaller MUST catch RequestError for network failures when using rp.put().costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - patch · http-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and options.simple is true (default)Throws
StatusCodeError with statusCode, error, options, and response propertiesRequired handlingCaller MUST catch StatusCodeError when using rp.patch(). PATCH requests to resources that don't exist (404) or where the user lacks permission (403) will reject by default.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - patch · network-failureerrorWhennetwork error, DNS failure, timeout, or connection refusedThrows
RequestError wrapping the underlying Node.js errorRequired handlingCaller MUST catch RequestError for network failures when using rp.patch().costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - del · http-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and options.simple is true (default)Throws
StatusCodeError with statusCode, error, options, and response propertiesRequired handlingCaller MUST catch StatusCodeError when using rp.del() or rp.delete(). DELETE on a resource that doesn't exist (404) or lacks permission (403) will reject. A 404 on a repeated DELETE is common — check statusCode before retrying.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - del · network-failureerrorWhennetwork error, DNS failure, timeout, or connection refusedThrows
RequestError wrapping the underlying Node.js errorRequired handlingCaller MUST catch RequestError for network failures when using rp.del().costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - head · http-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and options.simple is true (default)Throws
StatusCodeError with statusCode, error, options, and response propertiesRequired handlingCaller MUST catch StatusCodeError when using rp.head(). A 404 HEAD check for resource existence will reject by default — this is a common gotcha when using HEAD to probe whether a resource exists.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - head · network-failureerrorWhennetwork error, DNS failure, timeout, or connection refusedThrows
RequestError wrapping the underlying Node.js errorRequired handlingCaller MUST catch RequestError for network failures when using rp.head().costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - head · head-resolves-with-headers-not-bodywarningWhenrequest succeeds (2xx)ReturnsResponse headers object (not body) by default, because HTTP HEAD responses have no body. Set resolveWithFullResponse: true to get the full response object instead.Required handlingCallers MUST NOT expect a body from rp.head(). The resolved value is the response.headers object by default. This differs from all other HTTP method shortcuts which resolve with the body.costlowin prodsilent failureusers seelost datavisibilitysilentSources[8]
Sources
Every postcondition cites at least one of these. Numbered to match the footnotes above.
- [1]github.com/request/request-promisehttps://github.com/request/request-promise
- [2]github.com/request/request-promise-corehttps://github.com/request/request-promise-core/blob/master/lib/plumbing.js#L104
- [3]github.com/request/request-promise-corehttps://github.com/request/request-promise-core/blob/master/lib/plumbing.js#L87
- [4]github.com/request/request-promisehttps://github.com/request/request-promise#migration-from-v2-to-v3
- [5]github.com/request/request-promise-corehttps://github.com/request/request-promise-core/blob/master/lib/plumbing.js#L100
- [6]github.com/request/request-promise-corehttps://github.com/request/request-promise-core/blob/master/lib/errors.js
- [7]github.com/DefinitelyTyped/DefinitelyTypedhttps://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/request/index.d.ts
- [8]github.com/request/request-promise-corehttps://github.com/request/request-promise-core/blob/master/lib/plumbing.js#L62
Need a different package?
Request a profile