From 6339b85f76b95cfed163e4c327a1a212345f1bb2 Mon Sep 17 00:00:00 2001 From: Alex McKay <77302540+alex-mckay@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:27:18 -0400 Subject: [PATCH] Update proxy docs to include fetchApi Signed-off-by: Alex McKay <77302540+alex-mckay@users.noreply.github.com> --- docs/tutorials/using-backstage-proxy-within-plugin.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/tutorials/using-backstage-proxy-within-plugin.md b/docs/tutorials/using-backstage-proxy-within-plugin.md index 1abfe9e5b6..ed08362e65 100644 --- a/docs/tutorials/using-backstage-proxy-within-plugin.md +++ b/docs/tutorials/using-backstage-proxy-within-plugin.md @@ -114,20 +114,22 @@ look something like this: /* ... */ -import { DiscoveryApi } from '@backstage/core-plugin-api'; +import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api'; export class MyAwesomeApiClient implements MyAwesomeApi { discoveryApi: DiscoveryApi; + fetchApi: FetchApi; - constructor({discoveryApi}: {discoveryApi: DiscoveryApi}) { + constructor({discoveryApi, fetchApi}: {discoveryApi: DiscoveryApi, fetchApi: FetchApi}) { this.discoveryApi = discoveryApi; + this.fetchApi = FetchApi; } private async fetch(input: string, init?: RequestInit): Promise { // As configured previously for the backend proxy const proxyUri = `${await this.discoveryApi.getBaseUrl('proxy')}/`; - const resp = await fetch(`${proxyUri}${input}`, init); + const resp = await this.fetchApi.fetch(`${proxyUri}${input}`, init); if (!resp.ok) throw new Error(resp); return await resp.json(); }