Skip to content

Commit ed03669

Browse files
authored
refactor: redirect to 404 when spec is not found (#215)
1 parent 33c7acc commit ed03669

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/views/ProductShell.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,16 @@ async function fetchProduct () {
9090
9191
productStore.setProduct(productWithVersion)
9292
} catch (err) {
93+
productStore.setProduct(null)
94+
9395
console.error(err)
96+
97+
if (err.response?.status === 404) {
98+
router.push({
99+
name: 'not-found'
100+
})
101+
}
102+
94103
productError.value = getMessageFromError(err)
95104
}
96105
}
@@ -105,9 +114,11 @@ async function fetchDocumentTree () {
105114
}
106115
// @ts-ignore
107116
// overriding the axios response because we're specifying what we're accepting above
108-
const res = await documentationApi.listProductDocuments(requestOptions) as AxiosResponse<ListDocumentsTree, any>
117+
if (productStore.product) {
118+
const res = await documentationApi.listProductDocuments(requestOptions) as AxiosResponse<ListDocumentsTree, any>
109119
110-
productStore.setDocumentTree((res.data).data)
120+
productStore.setDocumentTree((res.data).data)
121+
}
111122
} catch (err) {
112123
if (err.response.status === 404) {
113124
productStore.setDocumentTree([])

0 commit comments

Comments
 (0)