对于以下代码:
const apolloClient = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: endpoint,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
})
});
我需要异步获取endpoint
和token
。我该怎么办?
谢谢
我认为您可以动态设置它by making the uri
a function。我不确定它是否每次发出请求时都会重新读取链接。看起来像这样(用TypeScript编写,但仍应可被JS解析)