Fix logs to reflect that empty snapshot is likely not an error

Additionally replace incorrect 404 message
This commit is contained in:
2023-08-15 12:15:31 +01:00
parent 63d2508423
commit 3be37dad99

View File

@ -20,8 +20,8 @@ exports.getStationData = functions.https.onRequest((request, response) => {
// fetch the "stations" collection
admin.firestore().collection('stations').get().then((snapshot) => {
if (snapshot.empty) {
functions.logger.log("Error fetching station data from Firestore")
response.status(404).send({data: "Error fetching station data from Firestore"})
functions.logger.log("Empty snapshot received when fetching station data from Firestore")
response.status(404).send({data: "Empty snapshot received when fetching station data from Firestore"})
return;
}
// iterate through each of the collection's documents
@ -185,8 +185,8 @@ exports.getLiveTrainData = functions.https.onRequest((request, response) => {
// fetch the "liveTrainData" collection
admin.firestore().collection('liveTrainData').get().then((snapshot) => {
if (snapshot.empty) {
functions.logger.log("Error fetching live train data from Firestore")
response.status(404).send({data: "Successfully fetched live train data from Firestore"});
functions.logger.log("Empty snapshot received when fetching live train data from Firestore")
response.status(404).send({data: "Empty snapshot received when fetching live train data from Firestore"});
return;
}
// iterate through each of the collection's documents
@ -489,4 +489,4 @@ exports.deletePreferences = functions.https.onCall((data, context) => {
functions.logger.log("Successfully deleted user preferences from Firestore")
return "Successfully deleted user preferences from Firestore"
})
})
})