Initial commit
This commit is contained in:
5
app/adapters/application.js
Normal file
5
app/adapters/application.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import DS from 'ember-data';
|
||||
|
||||
export default DS.RESTAdapter.extend({
|
||||
host: 'http://api.fias.hellotan.ru'
|
||||
});
|
||||
18
app/adapters/find-result.js
Normal file
18
app/adapters/find-result.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import ApplicationAdapter from './application';
|
||||
import Ember from 'ember';
|
||||
|
||||
export default ApplicationAdapter.extend({
|
||||
query: function(store, type, query) {
|
||||
var url = this.get('host')+'/find/'+query.text;
|
||||
Ember.Logger.log('url:', url);
|
||||
|
||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||
Ember.$.getJSON(url, query).then(function(data) {
|
||||
Ember.run(null, resolve, data);
|
||||
}, function(jqXHR) {
|
||||
jqXHR.then = null; // tame jQuery's ill mannered promises
|
||||
Ember.run(null, reject, jqXHR);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user