Skip to content

Commit 7179454

Browse files
authored
Check if response status is unprocessableEntity (#31)
This PR adds a convenient helper to check for unprocessableEntity response status. I bet we don't want to add a helper for each status code but this is motivated by the fact that Rails now returns 422 status code by default for form submission with error rails/rails#41026 So, we can legitimately expect doing this kind of check more often.
1 parent 32cfab1 commit 7179454

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/fetch_response.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export class FetchResponse {
1919
return this.statusCode === 401
2020
}
2121

22+
get unprocessableEntity () {
23+
return this.statusCode === 422
24+
}
25+
2226
get authenticationURL () {
2327
return this.response.headers.get('WWW-Authenticate')
2428
}

0 commit comments

Comments
 (0)