|
1 |
| -import {ReactNativeBlobUtilConfig} from "./types"; |
| 1 | +import { ReactNativeBlobUtilConfig } from "./types"; |
2 | 2 | import URIUtil from "./utils/uri";
|
3 | 3 | import fs from "./fs";
|
4 | 4 | import getUUID from "./utils/uuid";
|
5 |
| -import {DeviceEventEmitter} from "react-native"; |
6 |
| -import {FetchBlobResponse} from "./class/ReactNativeBlobUtilBlobResponse"; |
| 5 | +import { DeviceEventEmitter } from "react-native"; |
| 6 | +import { FetchBlobResponse } from "./class/ReactNativeBlobUtilBlobResponse"; |
| 7 | +import { CanceledFetchError } from ".class/ReactNativeBlobUtilCanceledFetchError"; |
7 | 8 | import ReactNativeBlobUtil from "./codegenSpecs/NativeBlobUtils";
|
8 | 9 |
|
9 | 10 | const emitter = DeviceEventEmitter;
|
@@ -55,7 +56,7 @@ emitter.addListener("ReactNativeBlobUtilMessage", (e) => {
|
55 | 56 | * @return {function} This method returns a `fetch` method instance.
|
56 | 57 | */
|
57 | 58 | export function config(options: ReactNativeBlobUtilConfig) {
|
58 |
| - return {fetch: fetch.bind(options)}; |
| 59 | + return { fetch: fetch.bind(options) }; |
59 | 60 | }
|
60 | 61 |
|
61 | 62 | /**
|
@@ -105,7 +106,7 @@ function fetchFile(options = {}, method, url, headers = {}, body): Promise {
|
105 | 106 | stream.open();
|
106 | 107 | info = {
|
107 | 108 | state: "2",
|
108 |
| - headers: {'source': 'system-fs'}, |
| 109 | + headers: { 'source': 'system-fs' }, |
109 | 110 | status: 200,
|
110 | 111 | respType: 'text',
|
111 | 112 | rnfbEncode: headers.encoding || 'utf8'
|
@@ -328,7 +329,7 @@ export function fetch(...args: any): Promise {
|
328 | 329 | subscriptionUpload.remove();
|
329 | 330 | stateEvent.remove();
|
330 | 331 | ReactNativeBlobUtil.cancelRequest(taskId, fn);
|
331 |
| - promiseReject(new Error("canceled")); |
| 332 | + promiseReject(new CanceledFetchError("canceled")); |
332 | 333 | };
|
333 | 334 | promise.taskId = taskId;
|
334 | 335 |
|
|
0 commit comments