...

/

Retrieving Products from Firebase

Retrieving Products from Firebase

Learn to retrieve data from the Firebase Realtime Database.

We need to retrieve products in the admin, admin/edit, category, and category/item routes from our database.

Retrieving data in the admin route

We need to list all the products on the admin route. Let’s open app/routes/admin.js and retrieve all the products:

Press + to interact
//app/routes/admin.js
import Route from '@ember/routing/route';
export default class AdminRoute extends Route {
model() {
let products = this.store.findAll('product');
return products;
}
}
  • Line 7: We use the Ember Data store to retrieve the products. The findAll() method first checks the records locally. If they’re not present ...