코딩,해볼까

05.13. [술술술_project. 6] MyPage Javascript 작업 (2) 본문

Back/TIL

05.13. [술술술_project. 6] MyPage Javascript 작업 (2)

떠굥 2023. 5. 13. 12:55
window.onload = () => {
    let token = localStorage.getItem('payload');
    console.log(token)
    // {"token_type":"access","exp":1684129273,"iat":1683949273,"jti":"236844dc07aa4cb0905e4712c95bb0b4","user_id":1}
    
    let user_id = token("user_id")
    let user_id = token["user_id"]
    // token is not a function

  	console.log(user_id)
    console.log(token.user_id)
    // undefined

    // 127.0.0.1/:1 Refused to execute script from 'http://127.0.0.1:5500/index.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
}

 

 

window.onload = () => {
    console.log('로딩 완료!')
    console.log(token)
    // const user_id = token[-2] undefiend
    const user_id = token.slice(-2, -1)
    console.log(user_id)
}

 

 

Comments