2
0

fix: 🐛 Smash tiny bugs

This commit is contained in:
Baptiste Arnaud
2022-02-22 16:30:41 +01:00
parent 6d455a3861
commit 1dc2264bdf
4 changed files with 33 additions and 21 deletions

View File

@ -17,13 +17,17 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
pass: password,
},
})
const info = await transporter.sendMail({
from: `"${from.name}" <${from.email}>`,
to,
subject: 'Your SMTP configuration is working 🤩',
text: 'This email has been sent to test out your SMTP config.\n\nIf your read this then it has been successful.🚀',
})
res.status(200).send({ message: 'Email sent!', info })
try {
const info = await transporter.sendMail({
from: `"${from.name}" <${from.email}>`,
to,
subject: 'Your SMTP configuration is working 🤩',
text: 'This email has been sent to test out your SMTP config.\n\nIf your read this then it has been successful.🚀',
})
res.status(200).send({ message: 'Email sent!', info })
} catch (err) {
res.status(500).send(err)
}
}
}

View File

@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { GoogleSpreadsheet } from 'google-spreadsheet'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { methodNotAllowed } from 'utils'
import { isDefined, methodNotAllowed } from 'utils'
import { getSession } from 'next-auth/react'
import { User } from 'db'
import { withSentry } from '@sentry/nextjs'
@ -23,17 +23,23 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
)
await doc.loadInfo()
return res.send({
sheets: await Promise.all(
Array.from(Array(doc.sheetCount)).map(async (_, idx) => {
const sheet = doc.sheetsByIndex[idx]
await sheet.loadHeaderRow()
return {
id: sheet.sheetId,
name: sheet.title,
columns: sheet.headerValues,
}
})
),
sheets: (
await Promise.all(
Array.from(Array(doc.sheetCount)).map(async (_, idx) => {
const sheet = doc.sheetsByIndex[idx]
try {
await sheet.loadHeaderRow()
} catch (err) {
return
}
return {
id: sheet.sheetId,
name: sheet.title,
columns: sheet.headerValues,
}
})
)
).filter(isDefined),
})
}
return methodNotAllowed(res)