Skip to content

Commit 5059c23

Browse files
fix: handle null response from the template presets endpoint (cherry-pick #18723) (#18724)
Co-authored-by: Hugo Dutka <hugo@coder.com>
1 parent e5a74a7 commit 5059c23

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

site/src/api/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ class ApiMethods {
12371237

12381238
getTemplateVersionPresets = async (
12391239
templateVersionId: string,
1240-
): Promise<TypesGen.Preset[]> => {
1240+
): Promise<TypesGen.Preset[] | null> => {
12411241
const response = await this.axios.get<TypesGen.Preset[]>(
12421242
`/api/v2/templateversions/${templateVersionId}/presets`,
12431243
);

site/src/pages/TasksPage/TasksPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ export const data = {
610610
templateVersionId: string,
611611
): Promise<Task> {
612612
const presets = await API.getTemplateVersionPresets(templateVersionId);
613-
const defaultPreset = presets.find((p) => p.Default);
613+
const defaultPreset = presets?.find((p) => p.Default);
614614
const workspace = await API.createWorkspace(userId, {
615615
name: `task-${generateWorkspaceName()}`,
616616
template_version_id: templateVersionId,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy