Return obj with error message instead of undefined

This commit is contained in:
Yarmo Mackenbach 2020-12-20 22:55:08 +01:00
parent 686f0e2a5e
commit a1ff96a1b9

View file

@ -124,7 +124,11 @@ const verify = async (input, fingerprint, opts) => {
return Promise.allSettled(promises).then((values) => { return Promise.allSettled(promises).then((values) => {
return values.map((obj, i) => { return values.map((obj, i) => {
if (obj.status == 'fulfilled') {
return obj.value return obj.value
} else {
return obj.reason
}
}) })
}) })
} }
@ -142,7 +146,11 @@ const verify = async (input, fingerprint, opts) => {
return Promise.allSettled(promises).then((values) => { return Promise.allSettled(promises).then((values) => {
return values.map((obj, i) => { return values.map((obj, i) => {
if (obj.status == 'fulfilled') {
return obj.value return obj.value
} else {
return obj.reason
}
}) })
}) })
} }
@ -266,9 +274,9 @@ const verify = async (input, fingerprint, opts) => {
const promiseTimeout = new Promise((res) => { const promiseTimeout = new Promise((res) => {
const objResult = { const objResult = {
isVerified: null, isVerified: false,
errors: 'verification_timed_out', errors: ['verification_timed_out'],
serviceproviderData: null, serviceproviderData: undefined,
} }
setTimeout(() => res(objResult), 5000) setTimeout(() => res(objResult), 5000)
}) })