mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-11 08:04:17 -08:00
Added response interceptor to axios response.
This interceptor checks for response code 404 and redicts the user if that is the case.
This commit is contained in:
parent
e488e2dc0a
commit
373bd9b962
|
@ -7,6 +7,17 @@ if (env === "development" || localStorage.dev === "dev") {
|
||||||
axios.defaults.baseURL = location.protocol + "//" + location.hostname + ":3001";
|
axios.defaults.baseURL = location.protocol + "//" + location.hostname + ":3001";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a response interceptor to catch 404 errors in dymanic routes such as /status/:slug
|
||||||
|
axios.interceptors.response.use(function (response) {
|
||||||
|
return response;
|
||||||
|
}, function (error) {
|
||||||
|
if(error.response.status === 404){
|
||||||
|
location.href = "/page-not-found";
|
||||||
|
}
|
||||||
|
console.log(error);
|
||||||
|
return Promise.reject(error);
|
||||||
|
});
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue