Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. const functions = require('firebase-functions');
  2. const admin = require('firebase-admin');
  3. admin.initializeApp();
  4. const language = require('@google-cloud/language');
  5. const client = new language.LanguageServiceClient();
  6. const express = require('express');
  7. const app = express();
  8.  
  9. app.post('/calculateAverage', async (request, response) => {
  10.  
  11. const bodyUserId = request.body.id
  12. let query = admin.database().ref(`/user_info/`);
  13.  
  14. try {
  15. const snapshot = await query.once('value');
  16. snapshot.forEach((childSnapshot) => {
  17. console.log("key: " + childSnapshot.key + " value: " + childSnapshot.val())
  18. });
  19.  
  20. response.send({"snapshot await": "ok"});
  21. } catch(error) {
  22. console.log('Error getting messages', error.message);
  23. response.send({"snapshot await error": error.message});
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement