Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140847

Google cloud function sometimes works and sometimes not

$
0
0

I'm using a onCreate function for Firestore to detect user signup and create a document using his user id. The problem is the function works sometimes and doesn't work other times. Also, I'm getting a "Function returned undefined, expected Promise or value" error all the time whenever the function run. I have tried many solutions which were given on similar questions but still no luck.

export const createNewUser = functions.auth.user().onCreate(user => {
  const userId = user.uid;

  const updateData = {
    ads_watched: 0,
    coins: 20000,
    gems: 0
  };

  admin.firestore().doc("cashon/" + userId)
  .set(updateData)
  .then(writeResult => {
      console.log("User Created result:", writeResult);
      return null;
  })
  .catch(err => {
      console.log(err);
      return null;
    });
});

Viewing all articles
Browse latest Browse all 140847

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>