yusuketk 7 лет назад
Родитель
Сommit
c6faae08c0
1 измененных файлов с 4 добавлено и 5 удалено
  1. 4 5
      lib/util/restQiitaAPI.js

+ 4 - 5
lib/util/restQiitaAPI.js

@@ -9,7 +9,6 @@ module.exports = function(Team, Token) {
   const token = Token;
 
   var options = {
-    url: `https://${team}.qiita.com`,
     method: 'GET',
     headers: {
       'Content-Type': 'application/json',
@@ -17,9 +16,9 @@ module.exports = function(Team, Token) {
     }
   };
 
-  function restAPI(path, options) {
+  function restAPI(path, team, options) {
     return new Promise((resolve, reject) => {
-      options.url = `${options.url}/api/v2/${path}`;
+      options.url = `https://${team}.qiita.com/api/v2/${path}`;
       request(options, function(err, res, body) {
         if (err) {
           return console.error('upload failed:', err);
@@ -32,7 +31,7 @@ module.exports = function(Team, Token) {
 
   restQiitaAPI.getQiitaUser = function() {
     return new Promise((resolve, reject) => {
-      restAPI('users', options)
+      restAPI('users', team, options)
       .then(function(res){
         return JSON.parse(res[0].toString());
       })
@@ -52,7 +51,7 @@ module.exports = function(Team, Token) {
 
   restQiitaAPI.getQiitaPages = function(pageNum) {
     return new Promise((resolve, reject) => {
-      restAPI(`items?page=${pageNum}&per_page=100`, options)
+      restAPI(`items?page=${pageNum}&per_page=100`, team, options)
       .then(function(res) {
         const pages = JSON.parse(res[0].toString());
         const total = res[1];