diff --git a/src/generate.js b/src/generate.js index 8b8fa83..48cea02 100644 --- a/src/generate.js +++ b/src/generate.js @@ -34,12 +34,24 @@ const options = { const axios = require("axios"); const cheerio = require("cheerio"); +const fs = require('fs'); axios.get(`https://github.com/${options.user}`) .then(generate) - .catch(() => {}); + .catch(() => { + generate(null) + }); function generate(res) { + if(res !== null){ + let data = JSON.stringify(res.data); + fs.writeFileSync('github-activity.json', data); + } + else { + let rawdata = fs.readFileSync('github-activity.json'); + res = {'data': JSON.parse(rawdata)}; + } + console.log(``); const $ = cheerio.load(res.data);