How do I pass data into a Google Sheets API call?

I’m trying to pass data from an async JS Object into this Google Sheets API call which is named write_data_3C

So here’s what the API call looks like, and I know that “parts” isn’t what should go inside the brackets, but I don’t know to to pass a variable into the API call.

I’ve been able to write things if they come from a table widget, but this data is coming from async JS objects that are fired off once a submit button is pushed.

The onClick JS runs fine until it gets to the end where I’ve written this:
.then((parts) => write_data_3C.run(parts))

So I’m not sure what I’m doing wrong or how Appsmith wants me to approach this task, the only error I get is message:“write_data_3C failed to execute”

I have also tried using a JS Object to make the request instead and get the same error

export default {
	threeC: async (partslist) => {
		//use async-await or promises
		console.log("WRITE_DATA js obj ran")
		console.log(partslist, "<-----------------------")
		try {
			// write data to database
			await write_data_3C.run(partslist)
			return partslist;
		} catch (error) {
			console.error(error);
			return Promise.reject("Error writing data to database");
		}
	}
}

This gives me the same error, so I’m wondering if it’s even possible to pass data into a GSheets API call, or if it has to be stored in a UI widget?

hi @dhawn !

Check this doc to see how to pass params to a query using this.params

I tried this for a gsheets query, and the JS code looks like this:
Screenshot 2023-03-01 at 01.29.40

the gsheets query looks like this:

1 Like

Spot on! This is exactly what I needed, thanks so much for your help!! :smiley:

Thanks for your continuous support and patience. We hope your issue is resolved now.

Let us know how did we do?
https://survey.frontapp.com/v2/09a400bf433bc9676d67/cf033880466844f07247e25e71ad0c43