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

Add a response.ok boolean similar to fetch API? #2036

Closed
KyleAMathews opened this issue Apr 29, 2022 · 4 comments · Fixed by #2043
Closed

Add a response.ok boolean similar to fetch API? #2036

KyleAMathews opened this issue Apr 29, 2022 · 4 comments · Fixed by #2043
Labels
enhancement This change will extend Got features good for beginner This issue is easy to fix ✭ help wanted ✭

Comments

@KyleAMathews
Copy link

It's quite handy and would ease migrating to got.

It's set to false if (res.statusCode < 200 || res.statusCode > 299) or true if in 200-299.

@sindresorhus
Copy link
Owner

sindresorhus commented Apr 29, 2022

Got throws on non-2xx/3xx status codes by default.

https://github.com/sindresorhus/got/blob/main/documentation/2-options.md#throwhttperrors

I'm open to adding a .ok property though. For users that set the throwHttpErrors to false.

@szmarczak szmarczak assigned szmarczak and unassigned szmarczak Apr 29, 2022
@szmarczak szmarczak added enhancement This change will extend Got features ✭ help wanted ✭ good for beginner This issue is easy to fix labels Apr 29, 2022
@IswaryaS
Copy link
Contributor

IswaryaS commented May 17, 2022

@szmarczak Saw your tag that this issue needs to be picked and that it is good for a beginner - I have couple of years work experience in writing code, and now would like to contribute to open source (completely new but want to learn). Do you think I can pick up this task? I've gotten a brief overview of the problem. But if I can be assigned to this, I would like to know more to help me resolve it. Thanks in advance.

@szmarczak
Copy link
Collaborator

@IswaryaS Feel free to pick this up.

You need to add ok property here and here. Don't forget to modify/add some tests.

@IswaryaS
Copy link
Contributor

@szmarczak - Thanks, have started on it.

@IswaryaS IswaryaS mentioned this issue May 17, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This change will extend Got features good for beginner This issue is easy to fix ✭ help wanted ✭
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants