jeudi 18 mai 2017

Where to put this ajax request in the app from the Ember tutorial

Starting with the super-rentals app from the Ember tutorial (github link)...

I want to add "Weather: 24C" to the rental-listing component using the JSON provided by api.openweathermap.org (which looks like this)

Where would be the "best-practices" place to put this ajax request?

Ember.$.getJSON(`http://ift.tt/2q0POYU}`)
    .then(function(json) {
      return JSON.parse(json).main.temp;
  });

Do I need to add a component, add a model, add a service, add a second adapter, modify the existing adapter? Something else? All of these? Is the problem that the tutorial uses Mirage? I ask this because when I think I'm getting close, I get an error like this:

Mirage: Your Ember app tried to GET 
'http://ift.tt/2qvZjTP',
     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?




Aucun commentaire:

Enregistrer un commentaire