From ab0ad915fbed1accb1fd6b92c434f4deb110d133 Mon Sep 17 00:00:00 2001 From: Sajal Verma Date: Fri, 24 Jan 2025 03:35:23 +0100 Subject: [PATCH 1/2] update(fix): Pick top-level json values from response's json object for pre-configured requests --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 0ecdf7d..1d2d768 100644 --- a/src/main.ts +++ b/src/main.ts @@ -586,7 +586,7 @@ class ShowOutputModal extends Modal { }; const parseAndCreate = (data: object) => (key: string) => { - const value = DataResponse.includes("->") ? nestedValue(data, key) : data[key]; + const value = DataResponse.includes("->") ? nestedValue(data, key) : data.json[key]; contentEl.createEl('b', { text: key + " : " + JSON.stringify(value, null, 2) }); }; From d690544748f699ceba998f43a80bbcf6114e6e7d Mon Sep 17 00:00:00 2001 From: Sajal Verma Date: Fri, 24 Jan 2025 16:02:28 +0100 Subject: [PATCH 2/2] refactor: Null assert on json object, use templated string to print response --- src/main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 1d2d768..0c84195 100644 --- a/src/main.ts +++ b/src/main.ts @@ -586,8 +586,8 @@ class ShowOutputModal extends Modal { }; const parseAndCreate = (data: object) => (key: string) => { - const value = DataResponse.includes("->") ? nestedValue(data, key) : data.json[key]; - contentEl.createEl('b', { text: key + " : " + JSON.stringify(value, null, 2) }); + const value = DataResponse.includes("->") ? nestedValue(data, key) : data.json?.[key]; + contentEl.createEl('b', { text: `${key} : ${JSON.stringify(value, null, 2)}` }); }; const requestOptions = {