Skip to content
View Kikemotos12's full-sized avatar

Block or report Kikemotos12

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Kikemotos12/README.md
  • 👋 Hi, I’m @Kikemotos12
  • 👀 I’m interested in ...
  • 🌱 I’m currently learning ...
  • 💞️ I’m looking to collaborate on ...
  • 📫 How to reach me ...
  • 😄 Pronouns: ...
  • ⚡ Fun fact: ...

import { Octokit } from "octokit";

const octokit = new Octokit({ });

async function getPaginatedData(url) { const nextPattern = /(?<=<)([\S]*)(?=>; rel="Next")/i; let pagesRemaining = true; let data = [];

while (pagesRemaining) { const response = await octokit.request(GET ${url}, { per_page: 100, headers: { "X-GitHub-Api-Version": "2022-11-28", }, });

const parsedData = parseData(response.data)
data = [...data, ...parsedData];

const linkHeader = response.headers.link;

pagesRemaining = linkHeader && linkHeader.includes(`rel=\"next\"`);

if (pagesRemaining) {
  url = linkHeader.match(nextPattern)[0];
}

}

return data; }

function parseData(data) { // If the data is an array, return that if (Array.isArray(data)) { return data }

// Some endpoints respond with 204 No Content instead of empty array // when there is no data. In that case, return an empty array. if (!data) { return [] }

// Otherwise, the array of items that we want is in an object // Delete keys that don't include the array of items delete data.incomplete_results; delete data.repository_selection; delete data.total_count; // Pull out the array of items const namespaceKey = Object.keys(data)[0]; data = data[namespaceKey];

return data; }

const data = await getPaginatedData("/repos/octocat/Spoon-Knife/issues");

console.log(data);

Popular repositories Loading

  1. Kikemotos12 Kikemotos12 Public template

    Config files for my GitHub profile.

    1

  2. .github .github Public

    Forked from community/.github

    1

  3. Fusion Fusion Public

    Forked from FusionIIIT/Fusion

    Currently merged : Ac-1 Ac-2 Ac-3 Ac-5 Ac-7 Os-1 Os-2 Os-3 Gad-1 Gad-2 Gad-6 Gad-7

    JavaScript 1