Adding notifier to API for 401 requests, meaning login has notification on fail.
This commit is contained in:
parent
b5a2480001
commit
b46d9847ad
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* API cache for cached request responses.
|
* API cache for cached request responses.
|
||||||
*/
|
*/
|
||||||
import { notificationStore } from "../store/notification"
|
import { notificationStore } from "../store"
|
||||||
let cache = {}
|
let cache = {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +34,9 @@ const makeApiCall = async ({ method, url, body, json = true }) => {
|
||||||
switch (response.status) {
|
switch (response.status) {
|
||||||
case 200:
|
case 200:
|
||||||
return response.json()
|
return response.json()
|
||||||
|
case 401:
|
||||||
|
notificationStore.danger("Invalid credentials")
|
||||||
|
return handleError(`Invalid credentials`)
|
||||||
case 404:
|
case 404:
|
||||||
notificationStore.danger("Not found")
|
notificationStore.danger("Not found")
|
||||||
return handleError(`${url}: Not Found`)
|
return handleError(`${url}: Not Found`)
|
||||||
|
|
Loading…
Reference in New Issue