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 filename: string
) => { ) => {
const gist = await gistGrabber(gistId); const gist = await gistGrabber(gistId);
if (gist?.files){ if (gist === null) return null;
const file = gist.files[filename]; if (!gist.files) return null;
return file return gist.files[filename];
}
return null;
}; };
// Get a Group of Gist files by ID // Get a Group of Gist files by ID