Created
October 10, 2022 08:15
-
-
Save PaulieScanlon/444ca57620a5fb4e146738832123848d to your computer and use it in GitHub Desktop.
Create the Serverless Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { GoogleSpreadsheet } = require('google-spreadsheet'); | |
const doc = new GoogleSpreadsheet(process.env.GOOGLE_SHEET_ID); | |
export default async function handler(req, res) { | |
const { | |
query: { id } | |
} = req; | |
try { | |
if (!id) { | |
throw new Error(); | |
} | |
await doc.useServiceAccountAuth({ | |
client_email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL, | |
private_key: process.env.GOOGLE_PRIVATE_KEY.replace(/\\n/gm, '\n') | |
}); | |
res.status(200).json({ message: 'A ok!' }); | |
} catch (error) { | |
res.status(500).json(error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment