Unexpected end of JSON input
check: async () => {
const user: IUser = JSON.parse(localStorage.getItem(ELocalStorage.USER) || "");
const { role, status } = user;
if (user) {
if (role === ERole.Admin || (role === ERole.User && status === EStatus.ACTIVE)) {
return {
authenticated: true,
redirectTo: "/data",
};
}
if (role === ERole.User && status === EStatus.PENDING) {
return {
authenticated: false,
redirectTo: "/pending",
};
}
}
return {
authenticated: false,
error: {
message: "User not found",
name: "Check failed",
},
redirectTo: "/login",
logout: true,
};
},check: async () => {
const user: IUser = JSON.parse(localStorage.getItem(ELocalStorage.USER) || "");
const { role, status } = user;
if (user) {
if (role === ERole.Admin || (role === ERole.User && status === EStatus.ACTIVE)) {
return {
authenticated: true,
redirectTo: "/data",
};
}
if (role === ERole.User && status === EStatus.PENDING) {
return {
authenticated: false,
redirectTo: "/pending",
};
}
}
return {
authenticated: false,
error: {
message: "User not found",
name: "Check failed",
},
redirectTo: "/login",
logout: true,
};
},Browser console show SyntaxError: Unexpected end of JSON input
also redirectTo: "/pending" not working
