I have an async function, that returns either a string(token) or false(if the user isn't logged in):
const isLoggedIn = async ()=>{
const token = getToken();
if(!token){
return false;
}
const { data } = await axios({
method: "get",
url: `${rootUrl}/login/isLoggedIn`, //
headers:{
token
}
});
if(data.content.isLoggedIn === 'true'){//
return token;
}else{
clear();
return false;
}
}
I was wondering how to properly document the @return of the function. It should convey the fact that the promise can be resolved with either a string or a boolean, something like this:
* @returns {Promise:string|boolean}
Is there some convention regarding this? Should i even mention that the function returns a promise?