Package Exports
- toggle-gist-star
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (toggle-gist-star) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
toggle-gist-star
Unstar the gist if you've already starred it, otherwise star it
const toggleGistStar = require('toggle-gist-star');
token = 'xxx'; // your Github API access token
toggleGistStar('908bced575270f6ef80e', {token})
.then(() => {
console.log('Starred https://gist.github.com/908bced575270f6ef80e');
return toggleGistStar('908bced575270f6ef80e', {token});
})
.then(() => {
console.log('Unstarred https://gist.github.com/908bced575270f6ef80e');
});
Installation
npm install toggle-gist-star
API
const toggleGistStar = require('toggle-gist-star');
toggleGistStar(gistId [, options])
gistId: String
(a gist ID, for example https://gist.github.com/tim/34309 → '34309'
)
options: Object
(gh-get
options)
Return: Promise
instance
It checks if a gist with the given ID is starred or not, then unstars it if it's already starred by the authenticated user, otherwise stars it.
The promise will be fulfilled with an http.IncomingMessage
object if successful, otherwise rejected with an error.
toggleGistStar('ab12852099', {token: 'xxxxxx'}).catch(err => {
err.message;
//=> '404 Not Found (Gist not found: https://gist.github.com/ab12852099)'
});
toggleGistStar('2790533', {token: 'invalid_token'}).catch(err => {
err.message;
//=> '401 Unauthorized (Bad credentials)'
});
License
Copyright (c) 2016 Shinnosuke Watanabe
Licensed under the MIT License.