-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47726be
commit 7abae8f
Showing
1 changed file
with
15 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import { waitForPromise } from '@ember/test-waiters'; | ||
|
||
export async function wrappedFetch(...args) { | ||
let responsePromise = fetch(...args); | ||
let responsePromise = fetch(...args); | ||
|
||
waitForPromise(responsePromise); | ||
waitForPromise(responsePromise); | ||
|
||
let response = await responsePromise; | ||
let response = await responsePromise; | ||
|
||
return new Proxy(response, { | ||
get(target, prop, receiver) { | ||
let original = Reflect.get(target, prop, receiver); | ||
return new Proxy(response, { | ||
get(target, prop, receiver) { | ||
let original = Reflect.get(target, prop, receiver); | ||
|
||
if (['json', 'text', 'arrayBuffer', 'blob', 'formData'].includes(prop)) { | ||
return (...args) => { | ||
let parsePromise = original(...args); | ||
if (['json', 'text', 'arrayBuffer', 'blob', 'formData'].includes(prop)) { | ||
return (...args) => { | ||
let parsePromise = original(...args); | ||
|
||
return waitForPromise(parsePromise); | ||
} | ||
} | ||
return waitForPromise(parsePromise); | ||
}; | ||
} | ||
|
||
return original; | ||
} | ||
}); | ||
return original; | ||
}, | ||
}); | ||
} | ||
|
||
export default wrappedFetch; |