...
|
...
|
@@ -9,6 +9,8 @@ |
|
|
const rp = require('request-promise');
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
const ApiUrl = 'http://api.yoho.yohoops.org/';
|
|
|
|
|
|
class API {
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -18,7 +20,7 @@ class API { |
|
|
*/
|
|
|
get(url, data) {
|
|
|
return rp({
|
|
|
url: `${this.server}${url}`,
|
|
|
url: `${ApiUrl}${url}`,
|
|
|
qs: data
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -28,12 +30,11 @@ class API { |
|
|
* @params: urls => Array[Object[url[string], data[object]]]
|
|
|
*/
|
|
|
multiGet(urls) {
|
|
|
var rps = [],
|
|
|
self = this;
|
|
|
var rps = [];
|
|
|
|
|
|
_.forEach(urls, function(el) {
|
|
|
rps.push(rp({
|
|
|
url: `${self.server}${el.url}`,
|
|
|
url: `${ApiUrl}${el.url}`,
|
|
|
qs: el.data
|
|
|
}));
|
|
|
});
|
...
|
...
|
@@ -50,7 +51,7 @@ class API { |
|
|
*/
|
|
|
post(url, data) {
|
|
|
return rp({
|
|
|
url: `${this.server}${url}`,
|
|
|
url: `${ApiUrl}${url}`,
|
|
|
method: 'post',
|
|
|
form: data
|
|
|
});
|
...
|
...
|
|