I need the get a token returned from a self executed js function:
const mytoken = (async () => {
const getCookieToken = Cookies.get("clIntegrationToken");
if (!getCookieToken || getCookieToken === "undefined") {
const auth = await authenticate('client_credentials', {
clientId: 'vuuLuWnTGhUayS4....',
clientSecret: '8O9ft8X...'
})
token = auth.accessToken;
Cookies.set("clIntegrationToken", token, {
expires: auth.expires
});
} else {
token = getCookieToken || "";
}
return token;
})();
let **abc**=mytoken.then((token) => {
return token;
});
abc is a promise. I need the token:
let abc=mytoken.then((token) => {
return token;
});