Skip to content

Option for not transforming error responses #131

@stevage

Description

@stevage

I realise I'm too late on this one, and just discovering request-promise now, but this (#86) seems like a really weird change. I'm using transform to extract part of the body of a successful API query. I can't really imagine ever wanting to apply the same function to both successful and unsuccessful queries.

Before:

        transform: function(body) {
            return body.files[Object.keys(body.files)[0]].content; // find the contents of the first file in the gist
        }

After:

        transform: function(body, response) {
            if (!(/^2/.test('' + response.statusCode))) { 
                return response
            }
            return body.files[Object.keys(body.files)[0]].content; // find the contents of the first file in the gist
        }

Seems like a lot of ugly boilerplate for nothing.

Perhaps an option, transformErrors: false, to restore the previous behaviour.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions