| 548 | }; |
| 549 | |
| 550 | const interceptFetch = (...handlers: Array<HttpHandler>) => { |
| 551 | return { |
| 552 | run: async <T>(fn: (...args: any[]) => Promise<T>): Promise<T> => { |
| 553 | const current = fetchHttpHandlerStorage.getStore(); |
| 554 | |
| 555 | if (current) { |
| 556 | current.push(...handlers); |
| 557 | return fn(); |
| 558 | } else { |
| 559 | return fetchHttpHandlerStorage.run(handlers, fn); |
| 560 | } |
| 561 | }, |
| 562 | }; |
| 563 | }; |
| 564 | |
| 565 | // This function will resolve the defaults of a property within an options object. |
| 566 | // If the options object is undefined, it will return the defaults for that property (passed in as the 3rd arg). |