From 5928e4d28dcaccd2b4a18bc2fd52d66f2334f02f Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Tue, 3 Oct 2023 13:11:03 +0200 Subject: [PATCH] fix: allow toJSON to fail --- src/api/v3/keyoxide_profile.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/api/v3/keyoxide_profile.js b/src/api/v3/keyoxide_profile.js index ed8ebd5..ef637a0 100644 --- a/src/api/v3/keyoxide_profile.js +++ b/src/api/v3/keyoxide_profile.js @@ -128,7 +128,13 @@ router.get('/fetch', data = await doVerification(data) } - data = data.toJSON() + try { + data = data.toJSON() + } catch (error) { + data = { + errors: [error.message] + } + } try { // Validate JSON @@ -162,7 +168,13 @@ router.get('/verify', // Do verification let data = await doVerification(profile) - data = data.toJSON() + try { + data = data.toJSON() + } catch (error) { + data = { + errors: [error.message] + } + } try { // Validate JSON