Created
September 14, 2016 09:39
-
-
Save planetexpress69/bd37e366cde1b587db715e3e0e0ff3f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
session: Ember.inject.service('session'), | |
selected: null, | |
query: "", | |
apiSettings: Ember.computed('session', function () { | |
var token = this.get('session.data.authenticated.access_token'); | |
return { | |
url: "https://**************/allports/?s={query}", | |
beforeXHR: function (xhr) { | |
xhr.setRequestHeader("Authorization", "Bearer " + token); | |
}, | |
}; | |
}), | |
actions: { | |
processResponse: function (arg) { | |
Ember.Logger.info(JSON.stringify(arg)); // response is fine! how do I proceed? How do I get the drop down kist filled with the records? | |
/* | |
Response looks like this: | |
[{"id":29230,"name":"Copenhagen","locode":"DKCPH"},{"id":9985,"name":"Freeport","locode":"BSFPO"},{"id":24050,"name":"Halmstad","locode":"SEHAD"},{"id":30780,"name":"Hamburg","locode":"DEHAM"},{"id":57822,"name":"Huangpu (Guangzhou)","locode":"CNHUA"},{"id":31650,"name":"Immingham","locode":"GBIMM"},{"id":48605,"name":"Muhamad Bin Qasim","locode":"PKBQM"},{"id":61480,"name":"Nagoya Ko","locode":"JPNGO"},{"id":48272,"name":"Sharjah","locode":"AESHJ"},{"id":57439,"name":"Songkhla","locode":"THSGZ"},{"id":35580,"name":"Southampton","locode":"GBSOU"},{"id":57870,"name":"Xiamen","locode":"CNXMN"},{"id":61390,"name":"Yokohama Ko","locode":"JPYOK"}] | |
*/ | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment