https://github.com/herber/nanogist
Isomorphic gist client
https://github.com/herber/nanogist
api gists github isomorphic
Last synced: 2 months ago
JSON representation
Isomorphic gist client
- Host: GitHub
- URL: https://github.com/herber/nanogist
- Owner: herber
- License: mit
- Created: 2018-02-13T07:00:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-13T07:00:48.000Z (over 8 years ago)
- Last Synced: 2025-09-28T01:52:05.504Z (9 months ago)
- Topics: api, gists, github, isomorphic
- Language: JavaScript
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Nanogist
Isomorphic gist client
## Install
```
$ npm install nanogist
```
## Usage
```js
const nanogist = require('nanogist');
const gist = nanogist('token');
gist.get('fa43cd476b09d1f10aebf4cac0351c4e').then((data) => {
console.log(data);
})
```
## API
## nanogist([token])
#### token
Type: `string`
Your OAuth token for accessing github's api.
If no token is supplied you can only create anonymous gists.
#### .get(id)
Get a gists content by it's id.
##### Example
```js
gist.get('50d1014b0e35be4675b6917719afb2de').then((content) => {
console.log('Username: ' + content.owner.login);
});
```
#### .create(data)
Create a new gist.
##### Example
```js
gist.create({
description: 'A new gist.',
public: false,
files: {
'home.txt': {
content: 'String file contents'
}
}
}).then((content) => {
console.log('ID:', data.id);
});
```
#### .update(id, data)
Update a gist.
##### Example
```js
gist.update('50d1014b0e35be4675b6917719afb2de', {
files: {
'home.txt': null,
'new_file.txt': {
content: 'a new file'
},
}
}).then((data) => {
console.log('Files:', data.files);
});
```
#### .delete(id)
Delete a gist.
##### Example
```js
gist.delete('50d1014b0e35be4675b6917719afb2de').then((deleted) => {
console.log(deleted);
})
```
## License
MIT © [Tobias Herber](http://tobihrbr.com)