APIFeed ES6 refactoring
This commit is contained in:
1 parent
f4bc70cd8b
commit
59b99cdad8
3 files changed
+19
-17
No files matched your search
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Created by tmshv on 22/11/14.
|
||||
*/
|
||||
|
||||
import {query} from '../../utils/net';
|
||||
import EndPoint from './EndPoint';
|
||||
|
||||
export default class APIFeed extends EndPoint{
|
||||
constructor(http){
|
||||
super(http)
|
||||
}
|
||||
|
||||
feed(count, portion) {
|
||||
let q = query([['count', count], ['portion', portion]]);
|
||||
return this.request.get(`/news?${q}`);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* Created by tmshv on 22/11/14.
|
||||
*/
|
||||
|
||||
var APINews = require("./news");
|
||||
import APIFeed from './APIFeed';
|
||||
var APIGallery = require("./gallery");
|
||||
import APIDocument from './APIDocument';
|
||||
|
||||
@@ -11,7 +11,7 @@ module.exports = function (app) {
|
||||
|
||||
app.factory("api", function ($http) {
|
||||
var api = {};
|
||||
api.news = new APINews($http);
|
||||
api.news = new APIFeed($http);
|
||||
api.gallery = new APIGallery($http, minute);
|
||||
api.document = new APIDocument($http);
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* Created by tmshv on 22/11/14.
|
||||
*/
|
||||
|
||||
import {query} from '../../utils/net';
|
||||
|
||||
function APIFeed(http){
|
||||
this.request = http;
|
||||
}
|
||||
|
||||
APIFeed.prototype.feed = function(count, portion) {
|
||||
return this.request.get("/news?"+query([["count", count], ["portion", portion]]));
|
||||
};
|
||||
|
||||
module.exports = APIFeed;
|
||||
Reference in new issue
Block a user