mikkopaderes / ember-firebase-service

Exposes a service that's a direct representation of Firebase
MIT License
4 stars 2 forks source link

Firebase Callable Functions #11

Closed danmalone89 closed 6 years ago

danmalone89 commented 6 years ago

Does this support firebase.functions().onCall? I'd like to use this call a Firebase Function from my route to retrieve some data but I'm unable to find any cases where anyone has accomplished this Ember. Thanks!

https://firebase.google.com/docs/functions/callable

mikkopaderes commented 6 years ago

It should as the firebase service is the firebase API itself

danmalone89 commented 6 years ago

Perfect. Thanks.

danmalone89 commented 6 years ago

@rmmmp Any chance you could help me understand why I'm receiving this.get(...).functions is not a function when specifying the model in my route?


/routes/contact.js
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service'
import RSVP from 'rsvp';

export default Route.extend({
    session: service('session'),
    firebase: service('firebase'),

    beforeModel: function() {
        return this.get('session').fetch().catch(function () {});
    },
    model(params) {
        return RSVP.hash({
            contactRecord:
                this.get('firebase').functions().httpsCallable('contactRecord')({contactId: params.contact_id})
                .then(recordResponse => {
                    return recordResponse;
                })
        });
    },
    setupController(controller, models) {
        controller.set('contactRecord', models.recordResponse);
        controller.set('UDFRecord', models.UDFResponse);
      }
});
mikkopaderes commented 6 years ago

Have you imported firebase-function as described in https://github.com/rmmmp/ember-firebase-service/blob/master/README.md#configuration?

danmalone89 commented 6 years ago

Turns out my firebase module didn't include firebase-functions.js because it was relying on an older version of firebase. Updated it, now I've got a build error because of conflicting versions of firebase! Womp womp.


+-- emberfire@2.0.10
| `-- firebase@3.9.0
`-- firebase@5.1.0
``
mikkopaderes commented 6 years ago

Yeah sadly there's nothing I can do about that if you're using emberfire. You'll have to wait for it to catch up to Firebase 5.x.