MCPcopy Index your code
hub / github.com/sallar/github-contributions-chart / fetchYears

Function fetchYears

src/utils/api/fetch.js:12–34  ·  view source on GitHub ↗
(username)

Source from the content-addressed store, hash-verified

10};
11
12async function fetchYears(username) {
13 const data = await fetch(`https://github.com/${username}?tab=contributions`, {
14 headers: {
15 "x-requested-with": "XMLHttpRequest"
16 }
17 });
18 const body = await data.text();
19 const $ = cheerio.load(body);
20 return $(".js-year-link.filter-item")
21 .get()
22 .map((a) => {
23 const $a = $(a);
24 const href = $a.attr("href");
25 const githubUrl = new URL(`https://github.com${href}`);
26 githubUrl.searchParams.set("tab", "contributions");
27 const formattedHref = `${githubUrl.pathname}${githubUrl.search}`;
28
29 return {
30 href: formattedHref,
31 text: $a.text().trim()
32 };
33 });
34}
35
36async function fetchDataForYear(url, year, format) {
37 const data = await fetch(`https://github.com${url}`, {

Callers 1

fetchDataForAllYearsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected