diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-21 09:49:26 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-21 09:49:26 -0700 |
commit | 7e96816f94314dcdf071eeee6e74a95bcace329f (patch) | |
tree | 21938fcdbe6e8b7a651308555af77c49dc59e1c2 /modern/src/SocketController.js | |
parent | 79dd42f0bdeef6d9f6331c0ec8301b2631a9cb90 (diff) | |
download | trackermap-web-7e96816f94314dcdf071eeee6e74a95bcace329f.tar.gz trackermap-web-7e96816f94314dcdf071eeee6e74a95bcace329f.tar.bz2 trackermap-web-7e96816f94314dcdf071eeee6e74a95bcace329f.zip |
Implement API error handling
Diffstat (limited to 'modern/src/SocketController.js')
-rw-r--r-- | modern/src/SocketController.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js index cf01ff7f..9826d4b1 100644 --- a/modern/src/SocketController.js +++ b/modern/src/SocketController.js @@ -49,6 +49,8 @@ const SocketController = () => { const response = await fetch('/api/server'); if (response.ok) { dispatch(sessionActions.updateServer(await response.json())); + } else { + throw Error(await response.text()); } }, []); @@ -57,6 +59,8 @@ const SocketController = () => { const response = await fetch('/api/devices'); if (response.ok) { dispatch(devicesActions.refresh(await response.json())); + } else { + throw Error(await response.text()); } connectSocket(); return () => { @@ -88,10 +92,6 @@ const SocketController = () => { {notifications.map((notification) => ( <Snackbar key={notification.id} - anchorOrigin={{ - vertical: 'bottom', - horizontal: 'right', - }} open={notification.show} message={notification.message} autoHideDuration={snackBarDurationLongMs} |