fix: retrieve total from github

This commit is contained in:
Kiril N. Nikolov 2016-11-03 14:24:17 +02:00
Родитель 7aef855675
Коммит 6ee2934edb
1 изменённых файлов: 22 добавлений и 31 удалений

Просмотреть файл

@ -3,44 +3,35 @@ var request = require('request');
export const fakeDataBase = {
get() {
const baseUrl = 'https://api.github.com/repos/telerik/kendo-ui-core';
const options = {
url: baseUrl,
headers: {
'User-Agent': 'kendoui',
'Authorization': "token 51bd04fc" +"379eb9d4e1d88637acfde27e445b7161"
}
}
var total = new Promise(function (resolve, reject) {
request(options, function(error, response, body) {
if (!error && response.statusCode === 200) {
resolve(JSON.parse(body).open_issues_count)
} else {
reject(error)
}
})
})
var issues = new Promise(function (resolve, reject) {
const options = {
url: baseUrl + '?state=all&page=1&per_page=20',
let baseUrl = 'https://api.github.com/repos/telerik/kendo-ui-core';
let options = {
url: baseUrl,
headers: {
'User-Agent': 'kendoui',
'Authorization': "token 51bd04fc" +"379eb9d4e1d88637acfde27e445b7161"
}
}
request(options, function(error, response, body) {
if (!error && response.statusCode === 200) {
resolve(JSON.parse(body))
} else {
reject(error)
}
const total = new Promise(function (resolve, reject) {
request(options, function(error, response, body) {
if (!error && response.statusCode === 200) {
resolve(JSON.parse(body).open_issues_count)
} else {
reject(error)
}
})
})
})
const issues = new Promise(function (resolve, reject) {
options.url += '/issues?state=all&page=1&per_page=10';
request(options, function(error, response, body) {
if (!error && response.statusCode === 200) {
resolve(JSON.parse(body))
} else {
reject(error)
}
})
})
return Promise.all([total, issues]);
}
};