Workflow with ember-data and ajax api call


#1

Hi,

I have this code in routes/index.js:

model( ) {
    return Ember.RSVP.hash( {
      maps: ajax( {
        url: '*********************',
        type: 'get'
      } ).then( function( data ) {
        console.log( 'maps: ', data );
        return data;
      } )
 } );
  }

which returns json data. Now I want to work with ember-data and a model, i have this code in models/map.js:

import DS from "ember-data";

export default DS.Model.extend( {
  gmap_lat_center: DS.attr( 'string' ),
  gmap_long_center: DS.attr( 'string' ),
  hotspots: DS.attr( 'array' ),
  id: DS.attr( 'string' ),
  image: DS.attr( 'array' ),
  image_highres: DS.attr( 'string' ),
  image_lowres: DS.attr( 'string' ),
  map_background: DS.attr( 'string' ),
  ne_lat: DS.attr( 'string' ),
  ne_long: DS.attr( 'string' ),
  order: DS.attr( 'string' ),
  sw_lat: DS.attr( 'string' ),
  sw_long: DS.attr( 'string' ),
  timestmap: DS.attr( 'string' ),
  title: DS.attr( 'string' ),
  track_geojson: DS.attr( 'string' ),
  type: DS.attr( 'string' ),
  zoom: DS.attr( 'string' )
} );

Now what is supposed to be the workflow with ajax and ember-data? Where do I need to put the ajax call and where do I store it in the models?

Kind regards,

Stijn