fix(integrations): 🐛 Get data when extracting 1 column
This commit is contained in:
@@ -17,8 +17,11 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
column: req.query['referenceCell[column]'],
|
column: req.query['referenceCell[column]'],
|
||||||
value: req.query['referenceCell[value]'],
|
value: req.query['referenceCell[value]'],
|
||||||
} as Cell
|
} as Cell
|
||||||
const extractingColumns = req.query.columns as string[] | undefined
|
|
||||||
if (!Array.isArray(extractingColumns)) return badRequest(res)
|
const extractingColumns = getExtractingColumns(
|
||||||
|
req.query.columns as string[] | string | undefined
|
||||||
|
)
|
||||||
|
if (!extractingColumns) return badRequest(res)
|
||||||
const doc = new GoogleSpreadsheet(spreadsheetId)
|
const doc = new GoogleSpreadsheet(spreadsheetId)
|
||||||
doc.useOAuth2Client(await getAuthenticatedGoogleClient(credentialsId))
|
doc.useOAuth2Client(await getAuthenticatedGoogleClient(credentialsId))
|
||||||
await doc.loadInfo()
|
await doc.loadInfo()
|
||||||
@@ -80,4 +83,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
return methodNotAllowed(res)
|
return methodNotAllowed(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getExtractingColumns = (columns: string | string[] | undefined) => {
|
||||||
|
if (typeof columns === 'string') return [columns]
|
||||||
|
if (Array.isArray(columns)) return columns
|
||||||
|
}
|
||||||
|
|
||||||
export default withSentry(handler)
|
export default withSentry(handler)
|
||||||
|
|||||||
Reference in New Issue
Block a user