Skip to content
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

Use node-fetch instead of cross-fetch #194

Merged
merged 1 commit into from
Dec 27, 2023
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
6 changes: 6 additions & 0 deletions .changeset/brave-owls-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@k-phoen/backstage-plugin-announcements-backend': patch
'@k-phoen/backstage-plugin-announcements': patch
---

Use node-fetch instead of cross-fetch
2 changes: 1 addition & 1 deletion plugins/announcements-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@backstage/plugin-search-common": "^1.2.9",
"@k-phoen/backstage-plugin-announcements-common": "^0.0.7",
"@types/express": "^4.17.6",
"cross-fetch": "^3.1.5",
"express": "^4.17.1",
"express-promise-router": "^4.1.0",
"knex": "^3.0.0",
Expand All @@ -53,6 +52,7 @@
},
"devDependencies": {
"@backstage/cli": "^0.25.0",
"@types/node-fetch": "^2.6.9",
"@types/supertest": "^2.0.8",
"@types/uuid": "^8.3.4",
"better-sqlite3": "^8.0.0",
Expand Down
14 changes: 7 additions & 7 deletions plugins/announcements-backend/src/search/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import crossFetch from 'cross-fetch';
import fetch from 'node-fetch';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { ResponseError } from '@backstage/errors';

Expand All @@ -21,12 +21,12 @@ export class AnnouncementsClient {
private async fetch<T = any>(input: string): Promise<T> {
const baseApiUrl = await this.discoveryApi.getBaseUrl('announcements');

return crossFetch(`${baseApiUrl}${input}`).then(async response => {
if (!response.ok) {
throw await ResponseError.fromResponse(response);
}
return response.json() as Promise<T>;
});
const response = await fetch(`${baseApiUrl}${input}`);
if (!response.ok) {
throw await ResponseError.fromResponse(response);
}

return response.json() as Promise<T>;
}

async announcements(): Promise<Announcement[]> {
Expand Down
1 change: 0 additions & 1 deletion plugins/announcements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"@testing-library/user-event": "^14.0.0",
"@types/luxon": "^3.2.0",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^1.0.0"
},
"files": [
Expand Down
1 change: 0 additions & 1 deletion plugins/announcements/src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
38 changes: 19 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4770,10 +4770,10 @@ __metadata:
"@backstage/plugin-search-common": ^1.2.9
"@k-phoen/backstage-plugin-announcements-common": ^0.0.7
"@types/express": ^4.17.6
"@types/node-fetch": ^2.6.9
"@types/supertest": ^2.0.8
"@types/uuid": ^8.3.4
better-sqlite3: ^8.0.0
cross-fetch: ^3.1.5
express: ^4.17.1
express-promise-router: ^4.1.0
knex: ^3.0.0
Expand Down Expand Up @@ -4824,7 +4824,6 @@ __metadata:
"@types/luxon": ^3.2.0
"@types/node": ^16.11.26
"@uiw/react-md-editor": ^3.19.5
cross-fetch: ^3.1.5
luxon: ^3.2.0
msw: ^1.0.0
react-use: ^17.2.4
Expand Down Expand Up @@ -6757,6 +6756,16 @@ __metadata:
languageName: node
linkType: hard

"@types/node-fetch@npm:^2.6.9":
version: 2.6.9
resolution: "@types/node-fetch@npm:2.6.9"
dependencies:
"@types/node": "*"
form-data: ^4.0.0
checksum: 212269aff4b251477c13c33cee6cea23e4fd630be6c0bfa3714968cce7efd7055b52f2f82aab3394596d8c758335cc802e7c5fa3f775e7f2a472fa914c90dc15
languageName: node
linkType: hard

"@types/node@npm:*":
version: 18.11.17
resolution: "@types/node@npm:18.11.17"
Expand Down Expand Up @@ -9765,15 +9774,6 @@ __metadata:
languageName: node
linkType: hard

"cross-fetch@npm:^3.1.5":
version: 3.1.5
resolution: "cross-fetch@npm:3.1.5"
dependencies:
node-fetch: 2.6.7
checksum: f6b8c6ee3ef993ace6277fd789c71b6acf1b504fd5f5c7128df4ef2f125a429e29cd62dc8c127523f04a5f2fa4771ed80e3f3d9695617f441425045f505cf3bb
languageName: node
linkType: hard

"cross-fetch@npm:^4.0.0":
version: 4.0.0
resolution: "cross-fetch@npm:4.0.0"
Expand Down Expand Up @@ -17228,31 +17228,31 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:2.6.7, node-fetch@npm:^2.6.7":
version: 2.6.7
resolution: "node-fetch@npm:2.6.7"
"node-fetch@npm:^2.6.12, node-fetch@npm:^2.6.9":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
dependencies:
whatwg-url: ^5.0.0
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
checksum: 8d816ffd1ee22cab8301c7756ef04f3437f18dace86a1dae22cf81db8ef29c0bf6655f3215cb0cdb22b420b6fe141e64b26905e7f33f9377a7fa59135ea3e10b
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
languageName: node
linkType: hard

"node-fetch@npm:^2.6.12, node-fetch@npm:^2.6.9":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
"node-fetch@npm:^2.6.7":
version: 2.6.7
resolution: "node-fetch@npm:2.6.7"
dependencies:
whatwg-url: ^5.0.0
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
checksum: 8d816ffd1ee22cab8301c7756ef04f3437f18dace86a1dae22cf81db8ef29c0bf6655f3215cb0cdb22b420b6fe141e64b26905e7f33f9377a7fa59135ea3e10b
languageName: node
linkType: hard

Expand Down