1.0.0 • Published 6 years ago

gh-post v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

gh-post

npm version Build Status Coverage Status

A Node module to create a POST request to the Github API

const ghPost = require('gh-post');

(async () => {
  const response = await ghPost('gists', {
    headers: {
      'user-agent': 'your application name'
    },
    token: 'your access token',
    body: {
      files: {
        'file1.txt': {
          content: 'Hi'
        }
      }
    }
  });

  response.headers.status; //=> '201 Created'
  response.headers.location; //=> for example 'https://api.github.com/gists/6ba9f11f4e1acf13645'
})();

Installation

Use npm.

npm install gh-post

API

const ghPost = require('gh-post');

ghPost(url, options)

url: string ("path" part of a Github API URL)
options: Object (gh-get options)
Return: Object (Promise instance)

Almost the same as gh-get, except that the method option defaults to 'POST' and unchangable.

License

Copyright (c) 2015 - 2018 Shinnosuke Watanabe

Licensed under the MIT License.