@mohammadsonu2004/github-users-api-wrapper

1.0.4 • Public • Published

github-users-api-wrapper

This NPM package functions as a wrapper to public Github users api.

Sample Usage

// Require/Import package
const githubUsersAPI = require("@mohammadsonu2004/github-users-api-wrapper");

/*
The package exposes two methods :
1. get_top_users
2. get_single_user
*/

// get_top_users() Usage
async function test1() {
  const response = await githubUsersAPI.get_top_users();
  // response is of type { data: SOME_VALUE | null, error: SOME_VALUE | null }
  // If call is successful:
  // data contains response and error is null
  // If call is unsuccessful:
  // data contains null and error contains error

  if (response.error) {
    // Some error occurred
    // Get exact error by reading response.error
  } else {
    // Successful response
    // Get response by reading response.data
  }
}

// get_single_user() Usage
async function test2() {
  // Pass userName as parameter to get_single_user function
  const response = await githubUsersAPI.get_single_user("mojombo");
  // response is of type { data: SOME_VALUE | null, error: SOME_VALUE | null }
  // If call is successful:
  // data contains response and error is null
  // If call is unsuccessful:
  // data contains null and error contains error

  if (response.error) {
    // Some error occurred
    // Get exact error by reading response.error
  } else {
    // Successful response
    // Get response by reading response.data
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @mohammadsonu2004/github-users-api-wrapper

Weekly Downloads

5

Version

1.0.4

License

ISC

Unpacked Size

3.31 kB

Total Files

4

Last publish

Collaborators

  • mohammadsonu2004