Skip to content

"Uncaught Error: You need to set token before by setToken() method" for public gist #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pozabil opened this issue Oct 13, 2022 · 2 comments

Comments

@pozabil
Copy link

pozabil commented Oct 13, 2022

Hello! Related to #1, I'm trying to get one gist by id in my rails application

document.addEventListener('turbolinks:load', function() {
	if ($('.gist-link')) {
		let GistClient = require("gist-client")
		let gistClient = new GistClient()

		$('.gist-link').each(function() {
			let gistId = $(this).attr('href').split('/').pop()

			console.log(gistId)

			gistClient.getOneById(gistId)
    			.then(response => {
    				console.log('RESPONSE')
        			console.log(response)
    			}).catch(err => {
    				console.log('ERROR')
        			console.log(err)
    			})
		})
	}
})

but i get error Uncaught Error: You need to set token before by setToken() method

I checked source code of lib, and find next lines in gist-client/lib/gistClient.js:

    this.getOneById = (gistId) => {
        _checkToken()
        return request(_getBaseConfiguredResource(API_DOMAIN + `/gists/${gistId}`))
            .then(res => { return res.data })
    }

getOneById function check token every time, when i try to get gist by id. I think this is a bug, right?

Best Regards!

@romatoom
Copy link

@pozabil I have the same problem. Have you solved it?

@pozabil
Copy link
Author

pozabil commented Dec 24, 2022

@romatoom

No, I just decided to use another library ( https://github.com/k33g/gh3 ), but install latest version from git master using bower dependencies.

But u can use this library, just downoad source code, and modified issued file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants