Skip to content

Remove ember-fetch dependency #10956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/models/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { cached } from '@glimmer/tracking';

import { apiAction } from '@mainmatter/ember-api-actions';
import { keepLatestTask, task } from 'ember-concurrency';
import fetch from 'fetch';
import { alias } from 'macro-decorators';
import semverParse from 'semver/functions/parse';

Expand Down Expand Up @@ -135,7 +134,7 @@ export default class Version extends Model {

loadReadmeTask = keepLatestTask(async () => {
if (this.readme_path) {
let response = await fetch(this.readme_path);
let response = await waitForPromise(fetch(this.readme_path));
if (response.status === 404 || response.status === 403) {
return;
}
Expand All @@ -144,7 +143,7 @@ export default class Version extends Model {
throw new Error(`README request for ${this.crateName} v${this.num} failed`);
}

return await response.text();
return await waitForPromise(response.text());
}
});

Expand Down
9 changes: 4 additions & 5 deletions app/utils/ajax.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { runInDebug } from '@ember/debug';

import fetch from 'fetch';
import { waitForPromise } from '@ember/test-waiters';

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

let cause;
try {
let response = await fetch(input, init);
let response = await waitForPromise(fetch(input, init));
if (response.ok) {
return await response.json();
return await waitForPromise(response.json());
}
cause = new HttpError({ url: input, method, response });
} catch (error) {
Expand Down Expand Up @@ -68,7 +67,7 @@ export class AjaxError extends Error {

async json() {
try {
return await this.cause.response.json();
return await waitForPromise(this.cause.response.json());
} catch {
// ignore errors and implicitly return `undefined`
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
"ember-error-route": "0.2.0",
"ember-event-helpers": "0.1.1",
"ember-exam": "9.1.0",
"ember-fetch": "8.1.2",
"ember-inflector": "6.0.0",
"ember-keyboard": "9.0.1",
"ember-link": "3.3.0",
Expand Down
Loading
Loading