data i get from external api is not saved in firestore database
but the record I added as last name xxxxx is successful wait db.collection('coins').add({lastName: 'xxxxxxx'}) this works but the code below does not
exports.firestoreKaydet = functions.firestore
.document("/users/{userId}")
.onCreate(async (snap, context) => {
await db.collection("coins").add({ lastName: "xxxxxxx" });
fetch(
"https://api.coinecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=1&sparkline=true"
)
.then((response) => response.json())
.then(async (data) => {
data.forEach(async (coin) => {
await db.collection("coins").add({
name: coin.name,
});
});
})
.catch((error) => {
console.error(error);
});
});