Fix TypeError (reading 'catch') (#742)

Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
ekzyis 2024-01-10 21:18:41 +01:00 committed by GitHub
parent c243a6d8be
commit c267bf92fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,6 @@ const toKV = (obj) => {
}
const slackPostMessage = ({ id, level, name, message, env, context }) => {
if (!slackClient) return
const text = `\`${new Date().toISOString()}\` | \`${id} [${level}] ${name}\` | ${message} | ${toKV(context)} | ${toKV({ os: env.os })}`
return slackClient.chat.postMessage({ channel: channelId, text })
}
@ -20,7 +19,7 @@ export default async (req, res) => {
const { id } = await models.log.create({ data: { level: level.toUpperCase(), name, message, env, context } })
slackPostMessage({ id, ...req.body }).catch(console.error)
if (slackClient) slackPostMessage({ id, ...req.body }).catch(console.error)
return res.status(200).json({ status: 200, message: 'ok' })
}