From 5660c94c6c089d73fb6b44cb2d2c1a15dc9093f3 Mon Sep 17 00:00:00 2001 From: teemoo7 Date: Mon, 17 Mar 2025 17:06:06 +0100 Subject: [PATCH] Fix code example in proxy tutorial doc for better consistency Signed-off-by: teemoo7 --- .../using-backstage-proxy-within-plugin.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/tutorials/using-backstage-proxy-within-plugin.md b/docs/tutorials/using-backstage-proxy-within-plugin.md index d5ce554239..88052c5f39 100644 --- a/docs/tutorials/using-backstage-proxy-within-plugin.md +++ b/docs/tutorials/using-backstage-proxy-within-plugin.md @@ -131,7 +131,7 @@ export class MyAwesomeApiClient implements MyAwesomeApi { const proxyUri = `${await this.discoveryApi.getBaseUrl('proxy')}/`; const resp = await this.fetchApi.fetch(`${proxyUri}${input}`, init); - if (!resp.ok) throw new Error(resp); + if (!resp.ok) throw new Error(resp.statusText); return await resp.json(); } @@ -151,8 +151,9 @@ export class MyAwesomeApiClient implements MyAwesomeApi { } ``` -> For more information on the DiscoveryApi check out the -> [docs](../reference/core-plugin-api.discoveryapi.md) +> Check out the docs for more information on the +> [DiscoveryApi](../reference/core-plugin-api.discoveryapi.md) or the +> [FetchApi](../reference/core-plugin-api.fetchapi.md) ## Bundling your ApiRef with your plugin @@ -171,6 +172,7 @@ import { createRoutableExtension, createComponentExtension, discoveryApiRef, + fetchApiRef, } from '@backstage/core-plugin-api'; //... @@ -182,8 +184,12 @@ export const myCustomPlugin = createPlugin({ apis: [ createApiFactory({ api: myAwesomeApiRef, - deps: { discoveryApi: discoveryApiRef }, - factory: ({ discoveryApi }) => new MyAwesomeApiClient({ discoveryApi }), + deps: { + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ discoveryApi, fetchApi }) => + new MyAwesomeApiClient({ discoveryApi, fetchApi }), }), ], });