File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33export const BASE_API_URL = "https://v2.api.noroff.dev" ;
44
55const AUTH_REGISTER_URL = `${ BASE_API_URL } /auth/register` ;
6- const AUTH_LOGIN_URL = ` ${ BASE_API_URL } /auth/login` ;
6+
77const registerForm = document . querySelector ( `#register-form` ) ;
8- const loginForm = document . querySelector ( `#login-form` ) ;
98
109async function registerUser ( userDetails ) {
1110 try {
Original file line number Diff line number Diff line change @@ -36,8 +36,23 @@ async function generatePosts(posts) {
3636 }
3737}
3838async function main ( ) {
39- const posts = await fetchPosts ( ) ;
40- generatePosts ( posts ) ;
41- console . log ( posts ) ;
39+ if ( ! localStorage . getItem ( "accessToken" ) ) {
40+ displayContainer . innerHTML = `
41+ <h1>Still</h1>
42+ <p>Get started at Still!</p>
43+ <div class="index-button-container">
44+ <button>Log in</button>
45+ <p>Or</p>
46+ <button>Create new profile</button>
47+ </div>` ;
48+ } else {
49+ try {
50+ const posts = await fetchPosts ( ) ;
51+ generatePosts ( posts ) ;
52+ } catch ( error ) {
53+ console . log ( error ) ;
54+ alert ( "Something wnt wrong, please return later!" ) ;
55+ }
56+ }
4257}
4358main ( ) ;
You can’t perform that action at this time.
0 commit comments