feat(integration): ♿️ Improve feedback on GSheets errors
This commit is contained in:
@ -17,6 +17,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (req.method === 'GET') {
|
||||
const credentialsId = req.query.credentialsId.toString()
|
||||
const auth = await getAuthenticatedGoogleClient(user.id, credentialsId)
|
||||
if (!auth)
|
||||
return res.status(404).send("Couldn't find credentials in database")
|
||||
const response = await drive({
|
||||
version: 'v3',
|
||||
auth,
|
||||
|
@ -19,9 +19,12 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
|
||||
const spreadsheetId = req.query.id.toString()
|
||||
const doc = new GoogleSpreadsheet(spreadsheetId)
|
||||
doc.useOAuth2Client(
|
||||
await getAuthenticatedGoogleClient(user.id, credentialsId)
|
||||
)
|
||||
const client = await getAuthenticatedGoogleClient(user.id, credentialsId)
|
||||
if (!client)
|
||||
return res
|
||||
.status(404)
|
||||
.send({ message: "Couldn't find credentials in database" })
|
||||
doc.useOAuth2Client(client)
|
||||
await doc.loadInfo()
|
||||
return res.send({
|
||||
sheets: (
|
||||
|
Reference in New Issue
Block a user