@daithi wrote:
complete noob to emberjs and am trying to figure out how to pull data from, for example meetup.com api, and display the results in a route. I'm using mirage for TDD.
My main issue is understanding the architecture to use with Emberjs. To get this data I should
1. create: model, route, template, adapter - all calledattend
.
2. In theattend adapter
make request to meetup and model the results making sure they match the whats definied in theattend model
. Then push this to astore
3. In theattend route
then return the store asmodel()
4. In theattend template
then the data can be accessed as|model|
5. mirage config should return mock data forGET /attend
route.But when I use the above method I end up creating my own API and the route then reads from that - which is not what I want to do. Simply I just want to get the data from meetup and display it.
So now I'm trying the following:
1. create route & templateattend
2. routemodel()
returns jquery call to meetup for data
3. mirageconfig.js
watchesGET https://.to.meetup.api
But I'm getting the error below...Mirage: Your Ember app tried to GET 'https://api.meetup.com/My-Cool-Meetup/events?photo-host=public&page=20&sig_id=xxxxxxxxxx&sig=xxxxxxxxx',
but there was no route defined to handle this request.
Define a route that matches this path in your
mirage/config.js file. Did you forget to add your namespace?app/routes/attend.js
import Ember from 'ember';export default Ember.Route.extend({ model(){ return $.getJSON('https://api.meetup.com/My-Cool-Meetup/events?photo-host=public&page=20&sig_id=xxxxxx&sig=xxxxxxxx'); } });
mirage/config.js
export default function() {
this.namespace = '/api';this.get('https://api.meetup.com/Dublin-Coder-Forge/events?photo-host=public&page=20&sig_id=183789567&sig=0c247a6dff1ac1cda1f65930c1923a3353074c30', function(){ return { "data": [{}], }; }); };
Now I'm wondering if I'm doing things the ember way at all - by right the data should be modeled, thus an adapter pattern, but I don't want to create or namespace
/api
- so adapter might mean something else in ember and complete overkill.lost down rabbit hole, any help appreciated.
Posts: 2
Participants: 1