Throw error if unexpected response code

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2020-06-07 01:00:46 +02:00 committed by mrdrogdrog
parent 8c4621ec97
commit 23c854dc9a

View file

@ -16,6 +16,8 @@ export const getBackendUrl: (() => string) = () => {
return store.getState().frontendConfig.backendUrl
}
export const expectResponseCode = (response: Response, code = 200): boolean => {
return response.status !== code
export const expectResponseCode = (response: Response, code = 200): void => {
if (response.status !== code) {
throw new Error(`response code is not ${code}`)
}
}