Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emberfire session not recognising any functions this.get(...).fetch is not a function TypeError: this.get(...).fetch is not a function #535

Open
rij12 opened this issue Dec 17, 2017 · 3 comments

Comments

@rij12
Copy link

rij12 commented Dec 17, 2017

I'm using emberfire to authenticate to a firebase database following the ember tutorial exactly with the following config:

//pods/application/route.js

  beforeModel: function() {
    return this.get("session").fetch().catch(function() {});
  },

  actions: {
    signIn: function(provider) {
      this.get('session').open('firebase', {
        provider: 'password',
        email: '[email protected]',
        password: 'password1234'
      });
    },
    signOut: function() {
      this.get("session").close();
    }
  }



//app/torii-adapters/application.js
import ToriiFirebaseAdapter from 'emberfire/torii-adapters/firebase';
export default ToriiFirebaseAdapter.extend({
  firebase: Ember.inject.service()

});

"emberfire": "^2.0.8",
"torii": "^0.9.6"


//config/environment
    firebase: 'https://FIREBASE_DATABASE_NAME.firebaseio.com',
    torii: {
      sessionServiceName: 'session'
    },

I get the following error:

router.js:936 Error while processing route: index this.get(...).fetch is not a function TypeError: this.get(...).fetch is not a function
Does anybody have any idea what's going on? I'm copying the tutorial to the letter.

@rij12 rij12 changed the title Emberfire session not recognising any functions Emberfire session not recognising any functions this.get(...).fetch is not a function TypeError: this.get(...).fetch is not a function Dec 17, 2017
@k-dauda
Copy link

k-dauda commented Feb 4, 2018

+1

1 similar comment
@lookininward
Copy link

+1

@fentech
Copy link

fentech commented Mar 13, 2019

I know this is super old, but you need to inject the service into the routes/controllers that need it. Also it looks like you are referencing your app/router.js file, when you should be doing this in either a controller (app/controller/controllerFile.js) or a route (app/routes/routeFile.js). Here's the docs on this.

// ⛔️ pods/application/route.js
// ✅ app/routes/route.js
import { inject as service } from '@ember/service';

export default Route.extend({
  session: service(),
  beforeModel: function() {
    return this.get("session").fetch().catch(function() {});
  },

  actions: {
    signIn: function(provider) {
      this.get('session').open('firebase', {
        provider: 'password',
        email: '[email protected]',
        password: 'password1234'
      });
    },
    signOut: function() {
      this.get("session").close();
    }
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants