Search⌘ K
AI Features

Retrieving Products from Firebase

Explore how to use Ember Data store methods to retrieve products from Firebase in different Ember.js application routes. Learn to fetch all products, specific items, and filtered lists based on parameters to handle product data effectively within your app.

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:

JavaScript (JSX)
//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 locally, it makes a network call to the Firebase Realtime Database. It searches for /products in the ...