SHARE
TWEET

Untitled

a guest Apr 21st, 2018 204 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Error: Invalid use of type "undefined" as a Firestore argument.
  2.     at Object.exports.customObjectError.val [as customObjectError] (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/validate.js:164:14)
  3.     at Function.encodeValue (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/document.js:808:20)
  4.     at Function.encodeFields (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/document.js:678:36)
  5.     at Function.fromObject (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/document.js:218:55)
  6.     at WriteBatch.set (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/write-batch.js:291:39)
  7.     at DocumentReference.set (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/reference.js:419:8)
  8.     at module.exports.addNewUser.functions.auth.user.onCreate.user (/user_code/functions/auth/index.js:22:73)
  9.     at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
  10.     at next (native)
  11.     at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
  12.    
  13. const functions = require('firebase-functions')
  14. const admin = require('firebase-admin')
  15.  
  16. admin.initializeApp();
  17.  
  18. exports.addNewUser = functions.auth
  19.     .user()
  20.     .onCreate(user => {
  21.         console.log(`user=${JSON.stringify(user)}`)
  22.  
  23.         return admin.firestore().collection(`users`).doc(`${user.uid}`).set({
  24.                 name: user.name,
  25.                 email: user.email
  26.             })
  27.             .then(() => {
  28.                 console.log("END")
  29.                 return
  30.             })
  31.             .catch((error) => {
  32.                 console.log(error)
  33.             });
  34.     })
  35.    
  36. admin.firestore().collection(`users`).doc(`${user.uid}`).set({
  37.     name: user.name,
  38.     email: user.email
  39. })
  40.    
  41. Invalid use of type "undefined" as a Firestore argument:
  42.    
  43. "firebase-admin": "^5.12.0",
  44. "firebase-functions": "^1.0.1",
  45.    
  46. service cloud.firestore {
  47.   match /databases/{database}/documents {
  48.     match /{document=**} {
  49.       allow read, write;
  50.     }
  51.   }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top