|
|
@@ -22,8 +22,9 @@ module.exports = function(Team, Token) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
options.path = `/api/v2/${path}`;
|
|
|
const req = https.request(options, (res) => {
|
|
|
+ const total = res.headers['total-count'];
|
|
|
res.on('data', (chunk) => {
|
|
|
- resolve(chunk);
|
|
|
+ resolve([chunk, total]);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -38,7 +39,7 @@ module.exports = function(Team, Token) {
|
|
|
restQiitaAPI.getQiitaUser = function() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
restAPI('users', options)
|
|
|
- .then(function(buf){
|
|
|
+ .then(function(buf, link){
|
|
|
return JSON.parse(buf.toString());
|
|
|
})
|
|
|
.then(function(user) {
|
|
|
@@ -46,7 +47,7 @@ module.exports = function(Team, Token) {
|
|
|
resolve(user);
|
|
|
}
|
|
|
else {
|
|
|
- reject('Unauthorized');
|
|
|
+ reject('Incorrect team name or access token.');
|
|
|
}
|
|
|
})
|
|
|
.catch(function(err){
|
|
|
@@ -55,11 +56,13 @@ module.exports = function(Team, Token) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- restQiitaAPI.getQiitaPages = function() {
|
|
|
+ restQiitaAPI.getQiitaPages = function(pageNum) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- restAPI('items', options)
|
|
|
- .then(function(page){
|
|
|
- resolve(JSON.parse(page.toString()));
|
|
|
+ restAPI(`items?page=${pageNum}&per_page=1`, options)
|
|
|
+ .then(function(res){
|
|
|
+ const page = res[0];
|
|
|
+ const total = res[1];
|
|
|
+ resolve([JSON.parse(page.toString()), total]);
|
|
|
})
|
|
|
.catch(function(err){
|
|
|
reject(err);
|