Posts

Showing posts with the label google-cloud-functions

No prediction results in response from Google ML Engine online prediction request

Image
No prediction results in response from Google ML Engine online prediction request I've got a model set up and running on Google ML Engine, which I can use successfully from my personal computer. Now I'm trying to set up Firebase Cloud Functions to make calls to my ML Engine model. I'm really close (I think) but I'm hitting a wall now. My prediction requests are being received by ML Engine, but I am not getting the prediction results in the callback function. results.predictions is always null, and when I stringified results I am seeing this: results.predictions results and Stackdriver shows the request being successfully sent: You can also see on the ML Engine Models dashboard, that the Last use time does reflect when I am calling the cloud function. Last use time But I can't figure out why I'm not getting the prediction results back from ML Engine. This is what I have been following as a guide for setting up my Cloud Functions: https://github.com/GoogleClo...

Firebase transaction in nodeJs

Image
Firebase transaction in nodeJs What I try to achieve is simply increase a value in the database with a transaction. This is working for me as intended, but I always get following error in my firebase console: Function returned undefined, expected Promise or value My current call is as following: exports.reportCounter = functions.database.ref('/user/{userId}/reports/{initiatorId}').onWrite((change,context) => { const userId = context.params.userId; return userRef.child(userId).child("numReports").transaction(function(numReports) { return change.after.exists()?((numReports || 0) + 1):(numReports - 1); }) }); I also tried returning the promise directly: return userRef.child(userId).child("numToIncrement").transaction(function(numToIncrement) { return ((numToIncrement || 0) + 1); }); In both cases, the code is doing what it is supposed to do, but I still receive said error. You should be able to return the promise ...

Delete Firestore Collection using firebase function

Image
Delete Firestore Collection using firebase function I am trying to set up a firebase function that deletes all subcollections of a document when the document is deleted. Trough reading the documentation I have come to this code: // The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers. const functions = require('firebase-functions'); // // Create and Deploy Your First Cloud Functions // // https://firebase.google.com/docs/functions/write-firebase-functions // // exports.helloWorld = functions.https.onRequest((request, response) => { // response.send("Hello from Firebase!"); // }); exports.DeleteColletionFunction = functions.firestore .document('exampleCollection/{exampleID}') .onDelete((snap, context) => { // Get an object representing the document prior to deletion // e.g. {'name': 'Marie', 'age': 66} const deletedValue = snap.data(); deleteCollection() }); funct...