0
我想獲得像github這樣的api的JSON數據。這是正確的方式嗎?Ember數據與RESTless JSON Api如github?
的Javascript:
var Github = window.Github = Ember.Application.create({
LOG_TRANSITIONS: true
});
Github.Adapter = DS.Adapter.extend({
find: function(store, type, id) {
//var url = type.url;
var url = "https://api.github.com/repos/emberjs/ember.js/commits";
//url = url.fmt(id);
jQuery.getJSON(url, function(data) {
// data is a hash of key/value pairs. If your server returns a
// root, simply do something like:
// store.push(type, id, data.person)
console.dir(data);
store.push(type, id, data);
});
}
});
Github.Commit = DS.Model.extend({
sha: DS.attr('string'),
url: DS.attr('string')
});
Github.Store = DS.Store.extend({
adapter: 'Github.Adapter'
});
Github.IndexRoute = Ember.Route.extend({
model: function() {
return Github.Store.find('commit');
}
});
HTML:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="http://builds.emberjs.com/tags/v1.2.0/ember.js"></script>
<script src="http://builds.emberjs.com/tags/v1.0.0-beta.3/ember-data.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
</body>
</html>
但問題是什麼?我不明白如何解釋這個說法。