Skip to content

Commit f109497

Browse files
whitphxgradio-pr-botaliabd
authored
Fix frontend errors on ApiDocs and RecordingSnippet (#9786)
* Fix frontend errors on ApiDocs and RecordingSnippet * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]> Co-authored-by: Ali Abdalla <[email protected]>
1 parent fc12496 commit f109497

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

.changeset/late-candies-boil.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/core": minor
3+
"gradio": minor
4+
---
5+
6+
feat:Fix frontend errors on ApiDocs and RecordingSnippet

js/core/src/Blocks.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@
806806
on:close={(event) => {
807807
set_api_docs_visible(false);
808808
api_calls = [];
809-
api_recorder_visible = event.detail.api_recorder_visible;
809+
api_recorder_visible = event.detail?.api_recorder_visible;
810810
}}
811811
{dependencies}
812812
{root}

js/core/src/api_docs/ApiDocs.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
{api_calls}
146146
{dependencies}
147147
{root}
148+
api_prefix={app.api_prefix}
148149
short_root={space_id || root}
149150
{username}
150151
/>

js/core/src/api_docs/RecordingSnippet.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
export let dependencies: Dependency[];
99
export let short_root: string;
1010
export let root: string;
11+
export let api_prefix = "";
1112
export let current_language: "python" | "javascript" | "bash";
1213
export let username: string | null;
1314
@@ -22,7 +23,9 @@
2223
named_endpoints: any;
2324
unnamed_endpoints: any;
2425
}> {
25-
let response = await fetch(root + "info/?all_endpoints=true");
26+
let response = await fetch(
27+
root.replace(/\/$/, "") + api_prefix + "/info/?all_endpoints=true"
28+
);
2629
let data = await response.json();
2730
return data;
2831
}
@@ -160,8 +163,7 @@ const app = await Client.connect(<span class="token string">"{short_root}"</span
160163
await client.predict(<span
161164
class="api-name">
162165
"/{api_name}"</span
163-
>{#if call},
164-
{/if}{call});
166+
>{#if call}, {call}{/if});
165167
{/each}</pre>
166168
</div>
167169
</code>

0 commit comments

Comments
 (0)