Skip to content

Treat any HTTP 2xx response as successful #21

@dossy

Description

@dossy

Specifically, I'm looking at these lines in src/index.js:

				if (res.statusCode === 200) {
					resolve(Object.assign({responseText, buffer}, res));
				} else {
					const error = new Error('Response error');
					error.responseText = responseText;
					reject(error);
				}

This test is a bit too strict: any HTTP status code bewteen 200 and 299 should be considered successful and not throw an error.

Also, it would be nice if the Error thrown, in addition to the responseText property, included a responseCode property that contained res.statusCode, as that's useful information when handling errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions