github-stats
github-stats copied to clipboard
Cannot read property 'appendChild' of null
index.js:54 Uncaught (in promise) TypeError: Cannot read property 'appendChild' of null
at index.js:54
When i tried to plug it in this error showed up. Can you look into it ? thank you!
@YatinGupta777 Please double check lines similar to line 63 & 73 in your initialization code snippet and make sure you have valid CSS selector ( where you want the statistics to show up ) inside querySelector.
https://github.com/byliuyang/github-stats/blob/193e4fd0b4197dc880e9573259882777c9d15ed9/examples/example.html#L62-L74
I have used the exact same javascript code as yours changing the username,commits container and language container These are the CSS selector i used
<div id="githubCommits">
</div>
<div id="githubLanguages">
</div>
variables
const GITHUB_USERNAME = 'YatinGupta777';
const COMMITS_CONTAINER = '#githubCommits';
const LANGUAGES_CONTAINER = '#githubLanguages';
@YatinGupta777 Hope I fixed the bug in the most recent release. I also updated the example code here: https://github.com/byliuyang/github-stats/blob/9bcb2519b77a04a6c326c78728eac6ce0b8a2cbd/examples/example.html#L6
https://github.com/byliuyang/github-stats/blob/9bcb2519b77a04a6c326c78728eac6ce0b8a2cbd/examples/example.html#L22-L70
If you get error, please try clear the cache in developer console:

If this didn't resolve your issue, please let me know.
For the next release, I am planing to support versioned cache.
Works great ! Thank you for creating this
Still happen randomly... it have to do with the cache, i am investigating this (weird because i did not had that issue before)
Disabling the cache solve the issue i will check that out later on but clearly it's not solved... it worked for me for 3 days while i am developing https://starhub.be (by the way thank you for your tool, i did integrate it on my app) but suddenly it started giving that error randomly...
any way a quick-fix awaiting final fix
function getCache(key) {
//return localStorage.getItem(`github-stats-${key}`);
return null;
}
function saveCache(key, value) {
//localStorage.setItem(`github-stats-${key}`, value);
}
function getJSONCache(key) {
//let value = getCache(key);
//return value ? JSON.parse(value) : null;
return null;
}
function saveJSONCache(key, value) {
//saveCache(key, JSON.stringify(value));
}
@intika Thank you for submitting the issue. I'll investigate when I have time.