mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
fix: return 404 if a fetch error or no data is returned
This commit is contained in:
@@ -179,7 +179,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
|
||||
} catch {
|
||||
return {
|
||||
props: {
|
||||
error: 'FetchError',
|
||||
notFound: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const data: string[] = await res.json();
|
||||
|
||||
if (!data.length) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
packageName,
|
||||
@@ -37,10 +43,10 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
|
||||
},
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return {
|
||||
props: {
|
||||
error: 'FetchError',
|
||||
notFound: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user