jvcalderon / gist-client

A client to consume Gist API with JS
MIT License
9 stars 0 forks source link

Is a token required for public gists? #1

Closed mindrones closed 5 years ago

mindrones commented 5 years ago

Hi, related to https://github.com/sveltejs/svelte.technology/issues/382, I'm trying to retrieve public gists containing the word "svelte":

const GistClient = require("gist-client");
const gistClient = new GistClient();

gistClient
.getAll({
    rawContent: true,
    filterBy: [
        {public: true},
        {content: "svelte"},
        {since: "2018-11-01T00:00:01Z"}
    ]
})
.then(gistList => {
    console.log(JSON.stringify(gistList))
})
.catch(err => {
    console.log(err)
});

but I get the error Error: You need to set token before by setToken() method. According to https://github.com/jvcalderon/gist-client#get-a-gist-list it seemed that this should work without a token? Thanks!

jvcalderon commented 5 years ago

This commit solves the problem. It was an unnecessary token check. Now (v.1.0.8) you can use getAll method without token, to retrieve public gists. Thank you for your feedback @mindrones

mindrones commented 5 years ago

Cool, worked perfectly to retrieve my own gists with this (no token):

.getAll({
    filterBy: [
        {userName: "mindrones"},
    ]
})

Thanks!

Note aside, this one:

.getAll({
    rawContent: true,
    filterBy: [
        {userName: "mindrones"},
        {content: "svelte"},
    ]
})

fails with a

TypeError: _.get(...).match is not a function
node_modules/gist-client/lib/gistClient.js:223:61

Not sure if that's supposed to work or wrong config. If needed can open a new issue.

jvcalderon commented 5 years ago

@mindrones I just published v.1.0.9 it solves a bug when gists files contained JSON files. You can see the change in this commit

mindrones commented 5 years ago

Works! Thanks a lot for these quick fixes, closing :)