apollo-link-rest: "Headers is not defined" occur when using apollo-link-rest in weixin mini program
- has-reproduction
When we try to use apollo-link-rest in weixin mini program, we encounted a problem which has throw an error as below:
Headers is not defined
ReferenceError: Headers is not defined
As I found the source code in RestLink.ts, it does try to find the Headers, but absolutely, there is no Headers under weixin environment, so can anyone help to provide some hack or solutions to solve this issue? Much appreciate if you could help, thanks.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 28
Here’s what ended up working for me:
I was able to fix this issue by using custom fetch
I solved this problem by using the fetch polyfill.
Something like the above might do the trick @2wheelcoder
@VinSpee 's solution worked for me for a Gatsby JS application as well.
Thanks @VinSpee —this was exactly what I needed