I am working on a Next JS app using google Sheet api for a personal project. Now this works completely fine on my local. But when I am deploying it to Netlify, this error pops up.
Can someone put up a solution? Thanks!
Here is my code:
import { google } from "googleapis";
export default async function form1(req, res){
if (req.method === 'POST') {
// Process a POST request
console.log("POST hit")
const auth = new google.auth.GoogleAuth({
keyFile: "credentials.json",
scopes: "https://www.googleapis.com/auth/spreadsheets",
})
//create client instancce
const client = await auth.getClient();
//instance of google sheet api
const googleSheets = google.sheets({version: "v4", auth: client});
const spreadsheetId = "*********55653"
//Write rows TO sheet
const {name, email, phone} = req.body;
await googleSheets.spreadsheets.values.append({
auth,
spreadsheetId,
range:"Subs!A:B",
valueInputOption: "USER_ENTERED",
resource: {
values: [
[name, email, phone]
],
}
})
res.send("Success")
} else {
// Handle any other HTTP method
res.status(405)
}
}