-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow users to visit an online space
closes #39
- Loading branch information
1 parent
e15599b
commit f7c9cfb
Showing
19 changed files
with
472 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { UNEXPECTED_ERROR_MESSAGE } from '../config/messages'; | ||
|
||
const createFlag = type => payload => dispatch => | ||
dispatch({ | ||
type, | ||
payload, | ||
}); | ||
|
||
const isErrorResponse = async response => { | ||
const LOWEST_HTTP_ERROR_CODE = 400; | ||
const HIGHEST_HTTP_ERROR_CODE = 599; | ||
|
||
if ( | ||
response.status >= LOWEST_HTTP_ERROR_CODE && | ||
response.status <= HIGHEST_HTTP_ERROR_CODE | ||
) { | ||
// assumes response has a message property | ||
const { message = UNEXPECTED_ERROR_MESSAGE } = await response.json(); | ||
|
||
throw Error(message); | ||
} | ||
}; | ||
|
||
export { createFlag, isErrorResponse }; |
Oops, something went wrong.