我想根据API响应更新firebase数据库中的一个字段,但是当我在google cloud中测试这个函数时,我得到了一个400错误。不确定我错过了什么:
import functions from 'firebase-functions';
import admin from 'firebase-admin';
import axios from 'axios';
const { initializeApp, credential: _credential, firestore} = admin;
admin.initializeApp();
const db = firestore();
async function UpdateCountField() {
console.log("Updating count task start point.");
const query = db.collection('users').where('count', '==', '');
return query.get().then(async snapshot => {
console.log(query.get('erd'));
let resptoken = await axios.get(
`https://api/${query.get('erd');
result = resptoken.data;
const promises = snapshot.docs.map(doc => doc.ref.update({ 'count': '${result}' }));
return Promise.all(promises)
})
}
1条答案
按热度按时间xdnvmnnf1#
最后用一种简单得多的方法