fix: allow toJSON to fail

This commit is contained in:
Yarmo Mackenbach 2023-10-03 13:11:03 +02:00
parent cf78f90251
commit 5928e4d28d
No known key found for this signature in database
GPG key ID: 3C57D093219103A3

View file

@ -128,7 +128,13 @@ router.get('/fetch',
data = await doVerification(data) data = await doVerification(data)
} }
try {
data = data.toJSON() data = data.toJSON()
} catch (error) {
data = {
errors: [error.message]
}
}
try { try {
// Validate JSON // Validate JSON
@ -162,7 +168,13 @@ router.get('/verify',
// Do verification // Do verification
let data = await doVerification(profile) let data = await doVerification(profile)
try {
data = data.toJSON() data = data.toJSON()
} catch (error) {
data = {
errors: [error.message]
}
}
try { try {
// Validate JSON // Validate JSON