Я развернул следующую облачную функцию:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.getAllUsers = functions.https.onRequest((req: any, res: any) => {
return admin.listUsers().then((userRecords: any) => {
userRecords.users.forEach((user: any) => console.log(user.toJSON()));
res.end('Retrieved all users successfully.');
}).catch((error: any) => console.log('Request failed: ', error));
})
Но всякий раз, когда я пытаюсь запустить его, я получаю следующую ошибку:
TypeError: admin.listUsers is not a function
at exports.getAllUsers.functions.https.onRequest (/srv/functions/lib/index.js:102:11)
at cloudFunction (/srv/functions/node_modules/firebase-functions/lib/providers/https.js:57:9)
at process.nextTick (/srv/node_modules/@google-cloud/functions-framework/build/src/invoker.js:243:17)
at process._tickCallback (internal/process/next_tick.js:61:11)
Как мне решить это? И как мне добавить параметр, чтобы разбить мои данные на страницы, то есть чтобы получить 100 пользователей за раз или что-то? Я ожидаю вызова конечной точки следующим образом: curl http://localhost:5000/sweltering-fire-5301/us-central1/getAllUsers. Как это будет выглядеть с параметром, т. Е. 'http://localhost:5000/sweltering-fire-5301/us-central1/getAllUsers?limit=5&page=2'