Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/gh-post
Create a POST request to the Github API
https://github.com/shinnn/gh-post
api-client github-api javascript nodejs request
Last synced: 27 days ago
JSON representation
Create a POST request to the Github API
- Host: GitHub
- URL: https://github.com/shinnn/gh-post
- Owner: shinnn
- License: mit
- Created: 2015-12-29T07:12:13.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-10-31T10:54:44.000Z (about 6 years ago)
- Last Synced: 2024-10-04T14:08:06.420Z (about 1 month ago)
- Topics: api-client, github-api, javascript, nodejs, request
- Language: JavaScript
- Size: 37.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gh-post
[![npm version](https://img.shields.io/npm/v/gh-post.svg)](https://www.npmjs.com/package/gh-post)
[![Build Status](https://travis-ci.org/shinnn/gh-post.svg?branch=master)](https://travis-ci.org/shinnn/gh-post)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/gh-post.svg)](https://coveralls.io/github/shinnn/gh-post?branch=master)A [Node](https://nodejs.org/) module to create a [`POST`](https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5) request to the [Github API](https://developer.github.com/v3/)
```javascript
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](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install gh-post
```## API
```javascript
const ghPost = require('gh-post');
```### ghPost(*url*, *options*)
*url*: `string` ("path" part of a Github API URL)
*options*: `Object` ([`gh-get` options](https://github.com/shinnn/gh-get#options))
Return: `Object` ([`Promise`](https://promisesaplus.com/) instance)Almost the same as [gh-get](https://github.com/shinnn/gh-get), except that the `method` option defaults to `'POST'` and unchangable.
## License
Copyright (c) 2015 - 2018 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).