-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (24 loc) · 855 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import DOMHandler from "./scripts/dom-handler.js";
import LoginPage from "./scripts/pages/#-page.js";
import HomePage from "./scripts/pages/home-page.js";
import { createUser } from "./scripts/services/users-service.js";
import { tokenKey, userEmail } from "./scripts/config.js";
import STORE from "./scripts/store.js";
async function init() {
try{
let token = sessionStorage.getItem(tokenKey)
if(!token) throw new Error()
STORE.user = sessionStorage.getItem(userEmail)
// STORE.user = sessionStorage.getItem(userEmail)
// console.log(STORE.user.email)
// const user = await getUser()
// STORE.user = user
await STORE.fetchContacts();
DOMHandler.load(HomePage)
} catch(error) {
sessionStorage.removeItem(tokenKey);
sessionStorage.removeItem(userEmail);
DOMHandler.load(LoginPage)
}
}
init()