Skip to content

Instantly share code, notes, and snippets.

@pangratz
Last active April 7, 2016 17:23
Show Gist options
  • Save pangratz/300ff114b6fb3a4aa37e99a1c31bbf37 to your computer and use it in GitHub Desktop.
Save pangratz/300ff114b6fb3a4aa37e99a1c31bbf37 to your computer and use it in GitHub Desktop.
import DS from "ember-data";
export default DS.JSONAPIAdapter.extend();
import Ember from 'ember';
import { server, json } from '../initializers/pretender';
server.map(function() {
this.get('/people', function() {
return json({
data: null
});
});
});
export default Ember.Route.extend({
model: function() {
return this.store.queryRecord('person', {}).then(function(person) {
console.log(person);
});
}
});
export function returnJSON(status, body) {
return json(...arguments);
};
export function json(status, body) {
if (arguments.length === 1) {
body = status;
status = 200;
}
return [
status,
{ "Content-Type": "application/json" },
JSON.stringify(body)
];
};
export const server = new Pretender();
export function initialize() {
server.handledRequest = function(verb, path, request) {
console.log(`handled request to ${verb} ${path}`);
}
server.unhandledRequest = function(verb, path, request) {
console.log(`undhandled request ${verb} ${path}`);
}
server.map(function() {
this.get('/people', returnJSON({
data: []
}));
});
};
export default {
name: 'pretender',
initialize
};
import DS from 'ember-data';
const { attr } = DS;
export default DS.Model.extend({
name: attr()
});
{
"version": "0.4.17",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.4.4",
"ember-data": "2.4.3",
"ember-template-compiler": "2.4.4",
"route-recognizer": "https://rawgit.com/tildeio/route-recognizer/56f5fcec6ae58d8e86b5dc77609809fb91198142/dist/route-recognizer.js",
"FakeXMLHttpRequest": "https://rawgit.com/pretenderjs/FakeXMLHttpRequest/23c3a96b5b24f1bfe595867437e4f128a29c2840/fake_xml_http_request.js",
"pretender": "https://rawgit.com/pretenderjs/pretender/c6de9afe18b1472aded2592f5a80ad9a26a0e262/pretender.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment