mardi 25 avril 2017

Catch a value from promise [duplicate]

This question already has an answer here:

I am currently working with an imdb-api which returns values with a promise. I am working with Ember and I don't know how to catch that variable to send it to the template.

import Ember from 'ember'
import imdb  from 'npm:imdb-api'

exports default Ember.Route.extend({
   model(params){
      this.movies = [];
      let search = Ember.get(params, 'search');
      imdb.get({name: search}).then(function(movies){
         //how can I do to change the value of this.movie 
         //this.movies= movies won't work because it's in a different scope
      })
   }
})




Aucun commentaire:

Enregistrer un commentaire