Refactor getGistFile function to handle null and missing files

This commit is contained in:
Adam Matthiesen 2024-03-14 09:23:38 -07:00
parent ed1b33b32a
commit ac0732423a
No known key found for this signature in database
GPG Key ID: 3F53281CB3936013
1 changed files with 3 additions and 5 deletions

View File

@ -99,11 +99,9 @@ export const getGistFile = async (
filename: string
) => {
const gist = await gistGrabber(gistId);
if (gist?.files){
const file = gist.files[filename];
return file
}
return null;
if (gist === null) return null;
if (!gist.files) return null;
return gist.files[filename];
};
// Get a Group of Gist files by ID