Giter Site home page Giter Site logo

github-integrate's Introduction

Fetching GitHub Commits

This document provides a detailed process for fetching GitHub commits using a helper function written in JavaScript.

Prerequisites

  • Node.js installed on your machine.
  • A GitHub personal access token with the necessary permissions.
  • The axios and moment libraries installed.

Step-by-Step Process

1. Import Required Libraries

First, import the necessary libraries: axios for making HTTP requests and moment for formatting dates.

import axios from "axios";
import moment from "moment";

2. Fetch the GitHub token from environment variables.

Rename .env.sample to .env and provide GitHub personal access token.

const { GITHUB_TOKEN } = process.env;

3. Call the Helper Function with the desired username and repository.

fetchCommits("your-username", "your-repository-name", "results-per-page"(OPTIONAL));

4. Get reponse for latest commits in descending order

[
  {
    Commit: '7c22ce7',
    Message: 'node_modules added to gitignore',
    Date: '10-07-2024 15:08:21 PM',
    URL: 'https://github.com/nilanjanhaldar24/sample-repo/commit/7c22ce70f0ebab7624e0c547d27137c651397f98',
    Author: 'Nilanjan Haldar',
    Username: 'nilanjanhaldar24'
  },
  {
    Commit: '9cb54bd',
    Message: 'first commit',
    Date: '10-07-2024 15:00:22 PM',
    URL: 'https://github.com/nilanjanhaldar24/sample-repo/commit/9cb54bdac63a33da3c1c4e90e156da298819634f',
    Author: 'Nilanjan Haldar',
    Username: 'nilanjanhaldar24'
  }
]

github-integrate's People

Contributors

nil2022 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.