Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat any HTTP 2xx response as successful #21

Open
dossy opened this issue Feb 21, 2022 · 0 comments · May be fixed by #22
Open

Treat any HTTP 2xx response as successful #21

dossy opened this issue Feb 21, 2022 · 0 comments · May be fixed by #22

Comments

@dossy
Copy link

dossy commented Feb 21, 2022

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.

dossy added a commit to dossy/simple-get-promise that referenced this issue Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant