Expected catch() or return (promise/catch-or-return)
The first error suggests you to use an arrow function as a callback. So you need to replace the regular functions, (function() { ... })
, with arrow functions, (() => { ... })
.
The second error suggests that you either need to catch the promise rejection, or return the promise itself. I am not too sure about your code but I believe that this method:
admin.database().ref('users/${uid}/referred_by').once('value')
returns a promise. So it needs to be returned like this:
return admin.database().ref('users/${uid}/referred_by').once('value')
or handle the error like this:
admin.database().ref('users/${uid}/referred_by').once('value')
// ... your code here
.catch(error => { ... });
As @Bergi pointed out in the comments that returning the promise is not preferable here, you may just add a catch
block to your promise.