From 1e6933851202732f6dd0ac06b33a8b29b804d9cf Mon Sep 17 00:00:00 2001 From: Shubham Gupta <61371540+brainspoof@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:45:48 +0530 Subject: [PATCH] Added multiple allowed status codes 200 is successful, but 201, and 202 should also be parsed. --- src/lib/components/AuthProvider.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/components/AuthProvider.js b/src/lib/components/AuthProvider.js index a588516..85339b7 100644 --- a/src/lib/components/AuthProvider.js +++ b/src/lib/components/AuthProvider.js @@ -12,6 +12,7 @@ class AuthProvider extends React.Component { this.fetchFail = this.fetchFail.bind(this); this.refreshAuth = this.refreshAuth.bind(this); this.state = { ...defaultState, refreshAuth: this.refreshAuth }; + this.allowed_status_codes = [200, 201, 202]; } componentDidMount () { if (this.props.authUrl) { @@ -52,7 +53,7 @@ class AuthProvider extends React.Component { this.toggleLoading(); return fetch(this.props.authUrl, options) .then(function(response) { - if (response.status !== 200) { + if (!this.allowed_status_codes.includes(response.status)) { return response.json() .then((r) => { return Promise.reject(r)