Skip to content

Commit 7fb22cd

Browse files
mansonaTurbo87
authored andcommitted
utils/ajax: Use native fetch() function
1 parent 478fbd3 commit 7fb22cd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

app/utils/ajax.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { runInDebug } from '@ember/debug';
2-
3-
import fetch from 'fetch';
2+
import { waitForPromise } from '@ember/test-waiters';
43

54
export default async function ajax(input, init) {
65
let method = init?.method ?? 'GET';
76

87
let cause;
98
try {
10-
let response = await fetch(input, init);
9+
let response = await waitForPromise(fetch(input, init));
1110
if (response.ok) {
12-
return await response.json();
11+
return await waitForPromise(response.json());
1312
}
1413
cause = new HttpError({ url: input, method, response });
1514
} catch (error) {
@@ -68,7 +67,7 @@ export class AjaxError extends Error {
6867

6968
async json() {
7069
try {
71-
return await this.cause.response.json();
70+
return await waitForPromise(this.cause.response.json());
7271
} catch {
7372
// ignore errors and implicitly return `undefined`
7473
}

0 commit comments

Comments
 (0)