I want to delete user from firebase using uid, It requires using Firebase Admin SDK but I have an error while calling the cloud function
the function code
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.deleteUserByUID = functions.https.onRequest(async (request, response) => {
const userID = request.body.uid;
admin.auth().deleteUser(userID)
.then(() => {
console.log('Successfully delete user.')
response.status(200).send('Deleted User')
return
})
.catch(error => {
console.log('Error deleting user:', error)
response.status(500).send('Failed')
})
})
calling function
var functions = Functions.functions()
functions.httpsCallable("deleteUserByUID").call(["uid": "M6AgnfIIlmXvjfXlgEGEE1ieDrf1"]) { (result, error) in
if error != nil {
print(error)
}
print result : Error Domain=com.firebase.functions Code=13 "INTERNAL" UserInfo={NSLocalizedDescription=INTERNAL}
