Changed the logic to catch error send by Klicktipp.

This commit is contained in:
elweyn 2021-10-13 11:32:00 +02:00
parent 3fdb503ea6
commit a1b54e592e

View File

@ -24,9 +24,13 @@ export const klicktippNewsletterStateMiddleware: MiddlewareFn = async (
const result = await next()
let klickTipp = new KlickTipp({ status: 'Unsubscribed' })
if (CONFIG.KLICKTIPP) {
const klickTippUser = await getKlickTippUser(result.email)
if (klickTippUser) {
klickTipp = new KlickTipp(klickTippUser)
try {
const klickTippUser = await getKlickTippUser(result.email)
if (klickTippUser) {
klickTipp = new KlickTipp(klickTippUser)
}
} catch (err) {
console.log('Something went wrong', err)
}
}
result.klickTipp = klickTipp