linagora / jmap-client-ts

JMAP 1.0 client library in TypeScript
MIT License
36 stars 16 forks source link

TypeError: 'fetch' called on an object that does not implement interface Window #74

Open EliRibble opened 3 weeks ago

EliRibble commented 3 weeks ago

I'm running on Firefox. Using the suggested sample code:

let client = new Client({
 ...
 transport: new FetchTransport(fetch)
})
client.fetchSession()...

Produces the error: TypeError: 'fetch' called on an object that does not implement interface Window. I think this has to do with rebinding fetch(). Instead, the following works for me:

let client = new Client({
 ...
 transport: new FetchTransport(fetch.bind(window))
})
client.fetchSession()...

See this Stack Overflow for possible explanation.