Here is a function I have:
function configureClient(): ApolloClient<ApolloCache<any>> {
let myToken = getOktaToken().then(token => {
return token
});
return new ApolloClient<InMemoryCache>({
uri: "someUrl",
cache: new InMemoryCache(),
headers: {
someAuth: myToken
}
});
}
I need to set someAuth: myToken
in the headers
of the return block, but I'm unsure how to do this using the then
block.
Additionally:
Normally, I would use
let myToken = await getOktaToken()
, however I cannot make the async function configureClient()
as the ApolloClient<ApolloCache<any>>
raises issues with ES3. Would this approach have worked?
Type 'typeof DefaultClient' in not a valid async function return type in ES5/ES3 because it does not refer to a Promise compatible constructor value