File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { runInDebug } from '@ember/debug' ;
2
-
3
- import fetch from 'fetch' ;
2
+ import { waitForPromise } from '@ember/test-waiters' ;
4
3
5
4
export default async function ajax ( input , init ) {
6
5
let method = init ?. method ?? 'GET' ;
7
6
8
7
let cause ;
9
8
try {
10
- let response = await fetch ( input , init ) ;
9
+ let response = await waitForPromise ( fetch ( input , init ) ) ;
11
10
if ( response . ok ) {
12
- return await response . json ( ) ;
11
+ return await waitForPromise ( response . json ( ) ) ;
13
12
}
14
13
cause = new HttpError ( { url : input , method, response } ) ;
15
14
} catch ( error ) {
@@ -68,7 +67,7 @@ export class AjaxError extends Error {
68
67
69
68
async json ( ) {
70
69
try {
71
- return await this . cause . response . json ( ) ;
70
+ return await waitForPromise ( this . cause . response . json ( ) ) ;
72
71
} catch {
73
72
// ignore errors and implicitly return `undefined`
74
73
}
You can’t perform that action at this time.
0 commit comments