Awmusic12635 / Wearables-Final-Group-Project

1 stars 1 forks source link

Firebase functions #16

Closed jrgabler closed 7 years ago

jrgabler commented 7 years ago

see routes/device.js for example usuage

using Promise.all() allows for the call of multiple get/list functions

example to get a list of buildings and a list of groups:

var list = require('../firebase/list');
//... things

// in your router.get function:
var firebaseData = {};

Promise.all([list("/buildings"), list("/groups")).then(function(snapshots) {
    firebaseData.buildings = snapshots[0];
    firebaseData.groups = snapshots[1];
    res.render("a-template", firebaseData);
  });