this.$auth.getAccessToken().then((token) => { //<---------blow up here saying it’s not a function.
this.$store.commit(‘SET_ACCESS_TOKEN’, token)
localStorage.setItem(‘token’, JSON.stringify(token))
apiClient.defaults.headers.common.Authorization = Bearer ${token}
})
I get an error that’s it’s not a function at runtime only.
Doesn’t look like its supposed to return a promise, just the access token string and our documentation does not indicate this is an async function as it does for others: getAccessToken | Okta Auth Javascript SDK
Hello, as you said, the doc define the function as string | undefined but the thing it is a Promise internally because the generation of a token take some time, I personally have problems with this, if a request is made to my backend and token expired, i have a hook to renew the token in the frontend, but some times it takes time and the result is the awkward error 401. I have see some code of okta and realized that in deed the function is a Promise but in some places it is just used a direct string. Why?