Following along with @swyx in this AMAZING video (3.5 hours intro to Netlify), and making the transition from a SSR Laravel App to a JAMstack masterpiece, I’m struck with this question.
If we have to do this on every component:
netlifyIdentity.init();
const user = netlifyIdentity.currentUser();
BEFORE we try to call a protected function:
let protectedData = this.$axios.get(`protected-function`,
user && {
headers: {
Authorization: 'Bearer ' + user.token.access_token,
accept: "Accept: application/json"
}
})
how is that any different then just checking the existence of user
within the component:
if (user){
let protectedData = this.$axios.get(`regular-not-protected-function`,
user && {
headers: {
Authorization: 'Bearer ' + user.token.access_token,
accept: "Accept: application/json"
}
})
}
I’m sure there’s something I’m missing here, but for now, it just looks like I’m repeating the logic in the protected function.