add function tokenLifeExtension
This commit is contained in:
+34
-3
@@ -18,10 +18,10 @@ export async function logout() {
|
||||
});
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} finally {
|
||||
await deleteSession();
|
||||
redirect('/login');
|
||||
}
|
||||
|
||||
await deleteSession();
|
||||
redirect('/login');
|
||||
}
|
||||
|
||||
export async function authorization(
|
||||
@@ -276,4 +276,35 @@ export async function registration(
|
||||
}
|
||||
|
||||
redirect('/pages/dashboard');
|
||||
}
|
||||
|
||||
export async function tokenLifeExtension() {
|
||||
const token = await getSessionData('token');
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
version: 1,
|
||||
msg_id: 20008,
|
||||
message_body: {
|
||||
token: token
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const parsed = await response.json();
|
||||
console.log('tokenLifeExtension');
|
||||
console.log(parsed.message_code);
|
||||
}
|
||||
} catch (error) {
|
||||
await deleteSession();
|
||||
redirect('/login');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user