mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 18:56:32 -05:00
Throw error if unexpected response code
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
8c4621ec97
commit
23c854dc9a
1 changed files with 4 additions and 2 deletions
|
@ -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}`)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue