Add GitHub branches (#1969)

This commit is contained in:
Max Arnold
2019-04-21 19:41:44 +07:00
committed by DIYgod
parent 697c231f4e
commit fe61f348da
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const user = ctx.params.user;
const repo = ctx.params.repo;
const host = `https://github.com/${user}/${repo}`;
const url = `https://api.github.com/repos/${user}/${repo}/branches`;
const response = await axios({
method: 'get',
url,
});
const data = response.data;
ctx.state.data = {
title: `${user}/${repo} Branches`,
link: `${host}/branches/all`,
item: data.map((item) => ({
title: item.name,
description: item.name,
link: `${host}/commits/${item.name}`,
})),
};
};