Reputation: 143
I'm getting the error when I'm using '?'. What should i use instead?
The error is:
Module parse failed: Unexpected token You may need an appropriate loader to handle this file type.
const accessToken = user?.accessToken
if(accessToken){
const decodedAccessToken = decode(accessToken)
if(decodedAccessToken.exp * 1000 < new Date().getTime()){
console.log(decodedAccessToken.exp);
renewAccessToken(user.user._id)
}
}
Upvotes: 1
Views: 663
Reputation: 143
I solved the problem. We have to use like this:
const accessToken = user ? user.accessToken : null;
Upvotes: 1