Add basic statistics with emulator handling

This commit is contained in:
Conor McNamara
2023-03-02 12:54:50 +00:00
parent 39a18f4820
commit f7e775188e
4 changed files with 25 additions and 20 deletions

View File

@ -18,7 +18,7 @@ exports.getLiveTrainData = functions.https.onRequest((request, response) => {
// fetch the "liveTrainData" collection
admin.firestore().collection('liveTrainData').get().then((snapshot) => {
if (snapshot.empty) {
response.send({data: "Error fetching live train data from the database"});
response.status(404).send({data: "Error fetching live train data from the database"});
return;
}
// iterate through each of the collection's documents
@ -40,7 +40,7 @@ exports.getStationData = functions.https.onRequest((request, response) => {
// fetch the "stations" collection
admin.firestore().collection('stations').get().then((snapshot) => {
if (snapshot.empty) {
response.send({data: "Error fetching station data from the database"})
response.status(404).send({data: "Error fetching station data from the database"})
return;
}
// iterate through each of the collection's documents