Browse Source

Move fetch to TS

pull/4695/head
Artur Arseniev 4 years ago
parent
commit
3defe24e7b
  1. 8
      src/utils/fetch.ts

8
src/utils/fetch.js → src/utils/fetch.ts

@ -1,3 +1,4 @@
// @ts-ignore
import Promise from 'promise-polyfill';
import { hasWin } from './mixins';
@ -6,9 +7,10 @@ if (hasWin()) {
}
export default typeof fetch == 'function'
? fetch.bind()
: (url, options) => {
return new Promise((res, rej) => {
? // @ts-ignore
fetch.bind()
: (url: string, options: Record<string, any>) => {
return new Promise((res: any, rej: any) => {
const req = new XMLHttpRequest();
req.open(options.method || 'get', url);
req.withCredentials = options.credentials == 'include';
Loading…
Cancel
Save