Google Cloud Platform TypeError: callback is not a function

Hi there!

I’m using my Particle Electron with a sensor to publish a String (text only) message every time it detects movement. I would like to integrate my Particle with Google Cloud Platform, and I have been following this great in depth tutorial by @rickkas7, but it seems to be outdated as it uses Node.js 6 which has been “deprecated” on Google Cloud functions for over a year now I believe…

Now I say that because when I try to deploy a function (say, the Google Sheets function), it gives me the error below


When I looked this problem up, a bunch of people said to add a “context” parameter to the function, which I tried, but I’m not sure if that solved my problem.

For reference, this is the code from the guide:

//Google API to allow access to sheets
const {google} = require('googleapis');

const sheets = google.sheets({version: 'v4'});

const dateFormat = require('dateformat');

const credentials = require("./credentials.json");

const config = require("./config.json");

 * Background Cloud Function to be triggered by Pub/Sub.
 * This function is exported by index.js, and executed when
 * the trigger topic receives a message.
 * @param {object} event The Cloud Functions event.
 * @param {function} callback The callback function.
exports.sheetsTest = (event, callback) => {
	const pubsubMessage =;

	// console.log("event", event);

	if (! {
		console.log("no data");

	var jsonData = JSON.parse(Buffer.from(, 'base64').toString());

	// console.log("jsonData", jsonData);
	var row = [];

	// This generates the columns for the row to add to the spreadsheet
	var d = Date.parse(pubsubMessage.attributes.published_at);
	row.push(dateFormat(d, 'm/d/yyyy HH:MM:ss'));
	const fields = ['a', 'b', 'c', 'n'];
	fields.forEach(function(field) {
		if (jsonData.hasOwnProperty(field)) {
		else {
	// This is the JWT authorization for the spreadsheet
	var jwt = new google.auth.JWT(
			credentials.client_email, null, credentials.private_key,
		spreadsheetId: config.spreadsheetId,
		range: 'A1',
		auth: jwt,
		key: config.apiKey,
		valueInputOption: 'USER_ENTERED',
		resource: {values: [row]}
	}, function(err, result) {
		if (err) {
			console.log("Error writing sheet", err);
		else {
			console.log('Updated sheet: ' +, row);


If anyone knows how I could fix this that would be greatly appreciated… Thank you!