Skip to content

Instantly share code, notes, and snippets.

@allthesignals
Last active July 4, 2016 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allthesignals/8ff65d1b994a0d207cbbfd83d6030bfa to your computer and use it in GitHub Desktop.
Save allthesignals/8ff65d1b994a0d207cbbfd83d6030bfa to your computer and use it in GitHub Desktop.
MapzenAPIProblem
import DS from 'ember-data';
import Ember from 'ember';
export default DS.JSONAPIAdapter.extend({
urlForFindRecord(id, modelName, snapshot) {
let url = this._super(...arguments);
let query = Ember.get(snapshot, 'adapterOptions.query');
if (query) {
url += '?' + Ember.$.param(query); // assumes no query params are present already
}
return url;
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
ajax: Ember.inject.service(),
appName: 'Ember Twiddle',
response: null,
actions: {
action: function() {
var response = this.get('ajax').request('https://search.mapzen.com/v1/autocomplete', {
method: 'GET',
dataType: "json",
data: {
"text": 'Boston',
"api_key": "search-5f1bwRf"
}
});
this.set('response', response);
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
<button {{action 'action'}}>A Button</button>
{{response}}
{{outlet}}
<br>
<br>
{
"version": "0.10.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js",
"ember": "2.3.2",
"ember-data": "2.6.1",
"ember-template-compiler": "2.3.2"
},
"addons": {
"ember-ajax": "2.4.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment