diff --git a/ayanova/src/api/apiutil.js b/ayanova/src/api/apiutil.js index 6901f2d1..709fca40 100644 --- a/ayanova/src/api/apiutil.js +++ b/ayanova/src/api/apiutil.js @@ -21,8 +21,6 @@ var stringifyPrimitive = function(v) { export default { status(response) { - //debugger; - if (response.status == 401) { //must reject if not authorized return Promise.reject(new Error("401 - NOT AUTHORIZED")); @@ -48,7 +46,6 @@ export default { } }, json(response) { - //debugger; return response.json(); }, apiErrorToHumanString(apiError) { @@ -171,26 +168,26 @@ export default { }, get(route) { var that = this; - //debugger; return new Promise(function(resolve, reject) { - //debugger; fetch(that.APIUrl(route), that.fetchGetOptions()) .then(that.status) .then(that.json) .then(response => { - //For now, assuming that all returns that make it here have either an error or a data object attached to them - // debugger; resolve(response); }) .catch(function(error) { //fundamental error, can't proceed with this call - // debugger; + var errorMessage = "API error: GET route =" + route + ", message =" + error.message; store.commit("logItem", errorMessage); alert("Error: " + errorMessage); reject(error); if (error.message && error.message.includes("401")) { + store.commit( + "logItem", + "User is not authorized, redirecting to login" + ); auth.logout(); router.push("/login"); }