Guest User

Untitled

a guest
Jan 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. var getData = function (id) {
  2. return new Promise(function (resolve, reject) {
  3. db.collection('users').doc(id).get()
  4. .then(function (doc) {
  5. if (doc.exists) {
  6. resolve(doc.data());
  7. }
  8.  
  9. reject('Document not found');
  10. })
  11. .catch(function (exception) {
  12. reject(exception);
  13. })
  14. });
  15. }
  16.  
  17. var id = 6;
  18.  
  19. getData(id).then(function (data) {
  20. console.log('Datos:', data);
  21. // Proceso a realizar
  22. }).catch(function (exception) {
  23. console.error('Exeption:', exception);
  24. });
Add Comment
Please, Sign In to add comment