I have generated a utility using ember generate util
and I'm trying to import it in another file, but I get a build error.
My utility (app/utils/swapi-adapter.js
):
import Ember from 'ember';
/* global $ */
export default Ember.Object.extend({
base: 'http://swapi.co/api/',
get: function(uri) {
var url = uri;
// make sure to append url
if(url.indexOf(this.get('base')) !== -1) {
url = this.get('base') + url;
}
return $.getJSON(url);
}
});
The route I'm trying to import it to: (app/routes/test-api.js
)
import Ember from 'ember';
import SWAPI from 'utils/swapi-adapter';
export default Ember.Route.extend({
model: {},
actions: {
test: function(url) {
SWAPI.get(url);
}
}
});
Aucun commentaire:
Enregistrer un commentaire