Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4831

Simple ember application with JSON model

$
0
0

@david9922 wrote:

Hi. I am building a simple application with Ember-Cli. I have a list of projects, I am displaying a list of projects on the index route, and on click I want to display the details of each project.

I ended up using mirage, and it is returning the list of projects fine, but I am having problems returning an specific project.

this is how my mirage confi,js looks like:

 _this.namespace = '/api';
this.get('/projects', function() {
    return {
      data: [{ id:'p1', type:"project", attributes: {image:"project1.jpg", description:"project 1 description"}},
        { id:"p2",type:"project", attributes: {image: "project2.jpg", description: "project 2 description"}}
    };
  });
   this.get('projects/:id', function(){
      //what should i return here?
   });_

My question is more about Ember architecture. Seems like Mirage should be used just for mocking, not sure if using it as a final solution is fine. I don't plan to connect the app to any database, as the data is simple enough.

  1. If my site model data is read only, what will be the best way to set it up so the data will be loaded from a read only json (on an external file, or hardcoded)? Is mirage the best option or is therea quicker way to do it?

  2. If mirage is the solution, how can I make a central repository (json) that I can use to define dynamic paths?

Thanks!

Posts: 9

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4831

Trending Articles