snt-voting/app/utils/fetchIdeas.js
Anshuman Verma 28e3fb20d2 Add linting rules, with husky and prettier (#64)
* Add linting rules, with husky and prettier

* Update lint-staged path

* final
2019-02-18 17:55:21 +00:00

30 lines
768 B
JavaScript

import axios from 'axios';
const repoFilter = repo => {
const { path } = repo;
if (path.includes('ideas')) {
const split = path.split('/');
if (split.length < 3) return true;
if (path.includes('README')) return true;
}
return false;
};
const convertToUrl = repo => {
const { path } = repo;
const base = 'https://ideas.status.im/';
const suffix = path.split('.md')[0];
return `${base}${suffix}`;
};
const fetchContent = async () => {
const response = await axios.get('https://api.github.com/repos/status-im/ideas/git/trees/master?recursive=1');
return response['data']['tree'].filter(repoFilter).map(convertToUrl);
};
const pluckIdeas = async () => {
const data = await fetchContent();
return data;
};
export default pluckIdeas;