After successfully receiving the desired response from an axios call to an API, my next task is to push that data into my Firebase Firestore. While I am confident in how to push data into Firestore, I am facing difficulty accessing the data correctly from the axios call for pushing. Here is the relevant snippet of code:
axios.get('https://somewhereontheweb.com/api/getgames', {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer ' + token,
}
})
.then(response => {
this.games = response.data;
// Need help with pushing data into Firestore here
})
.catch(function (error) {
console.log(error);
});
While I can display the JSON array received from the API on my Vue page as an object ({{games}}), my goal is to iterate over this data and push each game entry into Firestore. Although I am proficient in writing the Firestore push code, I am struggling with looping through the response to achieve this. Any guidance on how to approach this would be greatly appreciated.
Thank you!