From a1ff96a1b99fd198911addbb5231ea4403a0c2ee Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sun, 20 Dec 2020 22:55:08 +0100 Subject: [PATCH] Return obj with error message instead of undefined --- src/claims.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/claims.js b/src/claims.js index da091cb..c351c3f 100644 --- a/src/claims.js +++ b/src/claims.js @@ -124,7 +124,11 @@ const verify = async (input, fingerprint, opts) => { return Promise.allSettled(promises).then((values) => { return values.map((obj, i) => { - return obj.value + if (obj.status == 'fulfilled') { + return obj.value + } else { + return obj.reason + } }) }) } @@ -142,7 +146,11 @@ const verify = async (input, fingerprint, opts) => { return Promise.allSettled(promises).then((values) => { return values.map((obj, i) => { - return obj.value + if (obj.status == 'fulfilled') { + return obj.value + } else { + return obj.reason + } }) }) } @@ -266,9 +274,9 @@ const verify = async (input, fingerprint, opts) => { const promiseTimeout = new Promise((res) => { const objResult = { - isVerified: null, - errors: 'verification_timed_out', - serviceproviderData: null, + isVerified: false, + errors: ['verification_timed_out'], + serviceproviderData: undefined, } setTimeout(() => res(objResult), 5000) })