I am trying to create a task using Google Cloud Tasks but i'm encountering an error.
My code compiles perfectly but when it reaches the Cloud Tasks initialization line:
const data = snap.data();
let expirationInSeconds
if(data.booking_date_ts - Date.now() > 172800000){
expirationInSeconds = (Date.now() + 172800000) / 1000
}else{
expirationInSeconds = (Date.now() + 180000) / 1000
}
const project = JSON.parse(process.env.FIREBASE_CONFIG).projectId
const location = 'us-central1'
const queue = 'reminders'
const tasksClient = new CloudTasksClient() // This is the error line
const queuePath = tasksClient.queuePath(project, location, queue)
const url = `https://${location}-${project}.cloudfunctions.net/bookingExpirationCallback`
const docPath = snap.ref.path
const payload = { docPath }
const task = {
httpRequest: {
httpMethod: 'POST',
url,
body: Buffer.from(JSON.stringify(payload)).toString('base64'),
headers: {
'Content-Type': 'application/json',
},
},
scheduleTime: {
seconds: expirationInSeconds
}
}
return await tasksClient.createTask({ parent: queuePath, task });
i am getting the following error:
Error: Node.js v10.0.0 is a minimum requirement
which is weird because their documentation says:
Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.
and my current Node.js version is: v12.16.3