fix: apiでネイティブfetchを格納する際に無名関数でラップするように (#29)

* fix fetch

* add comment

* 表現を変更
This commit is contained in:
tamaina 2021-09-21 19:45:07 +09:00 committed by GitHub
parent f278390012
commit b7fd9e8c55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,7 +46,9 @@ export class APIClient {
}) { }) {
this.origin = opts.origin; this.origin = opts.origin;
this.credential = opts.credential; this.credential = opts.credential;
this.fetch = opts.fetch || fetch; // ネイティブ関数をそのまま変数に代入して使おうとするとChromiumではIllegal invocationエラーが発生するため、
// 環境で実装されているfetchを使う場合は無名関数でラップして使用する
this.fetch = opts.fetch || ((...args) => fetch(...args));
} }
public request<E extends keyof Endpoints, P extends Endpoints[E]['req']>( public request<E extends keyof Endpoints, P extends Endpoints[E]['req']>(