From dadd501843f76720905030b8679485f34ecd9a4d Mon Sep 17 00:00:00 2001 From: Ben Phelps Date: Thu, 29 Sep 2022 11:40:09 +0300 Subject: [PATCH] fix case with empty bookmarks and widgets --- src/utils/config/api-response.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/config/api-response.js b/src/utils/config/api-response.js index 1b4c1b5f..809927d1 100644 --- a/src/utils/config/api-response.js +++ b/src/utils/config/api-response.js @@ -14,6 +14,8 @@ export async function bookmarksResponse() { const fileContents = await fs.readFile(bookmarksYaml, "utf8"); const bookmarks = yaml.load(fileContents); + if (!bookmarks) return []; + // map easy to write YAML objects into easy to consume JS arrays const bookmarksArray = bookmarks.map((group) => ({ name: Object.keys(group)[0], @@ -33,6 +35,8 @@ export async function widgetsResponse() { const fileContents = await fs.readFile(widgetsYaml, "utf8"); const widgets = yaml.load(fileContents); + if (!widgets) return []; + // map easy to write YAML objects into easy to consume JS arrays const widgetsArray = widgets.map((group) => ({ type: Object.keys(group)[0],