Read JSON from static file

Hi guys!

I would like some help here.

I’m trying to read a static JSON file in order to test my Front End.

I’m using JSONAPIAdapter. I created the Serializers and the Adapter and pointed to the url for the JSON file, but the output of the url in Ember Inspect is being “localhost: 4200 / api / timelines” and is returning Not Found.

Could someone help me understand what the concept of Ember I did not understand very well when I tried to set up?

That’s my files:

app/serializers/application.js

import DS from 'ember-data';
export default DS.JSONAPISerializer.extend({
  keyForAttribute: function(attr) {
    return Ember.String.underscore(attr);
  }
});

app/adapters/application.js

import DS from 'ember-data';

export default DS.JSONAPIAdapter.extend({
   namespace: "api/",
   url: "timelines.json"
});

app/models/timelines.js

import DS from "ember-data";

export default DS.Model.extend({
    channel: DS.attr('string')
});

app/router.js

import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
  location: config.locationType
});

Router.map(function() {
    this.route('timelines', { path: '/' });
});

export default Router;

app/routes/timelines.js

import Ember from 'ember';

export default Ember.Route.extend({
    model () {
        return this.store.findAll('timeline');
    }
});

app/api/timelines.json

{
  "data": [{
    "type": "timelines",
    "id": "1",
    "attributes": {
      "channel": "facebook"
    }
  }, {
    "type": "timelines",
    "id": "2",
    "attributes": {
      "channel": "instagram"
    }
  }]
}

Take a look at my answer to a similar question. Hope that helps!