{"size": 1080, "ext": "js", "max_stars_repo_path": "src/js/util/getJSON.js", "max_stars_repo_name": "phamtheson01/interactivemapdota", "max_stars_repo_stars_event_min_datetime": "2016-12-27T22:02:01.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-08T17:29:27.000Z", "max_issues_repo_path": "src/js/util/getJSON.js", "max_issues_repo_name": "phamtheson01/interactivemapdota", "max_issues_repo_issues_event_min_datetime": "2017-04-26T13:18:23.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-15T01:26:35.000Z", "max_forks_repo_path": "src/js/util/getJSON.js", "max_forks_repo_name": "phamtheson01/interactivemapdota", "max_forks_repo_forks_event_min_datetime": "2017-01-04T01:10:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-13T13:34:35.000Z"}
{"max_stars_count": 48, "max_issues_count": 9, "max_forks_count": 10, "avg_line_length": 25.1162790698, "max_line_length": 72, "alphanum_fraction": 0.3990740741}
const getJSON = (path, callback) => {
    let retries = 3;

    const makeReq = () => {
        const request = new XMLHttpRequest();

        request.open('GET', path, true);
        let err;
        request.onload = () => {
            let data;
            if (request.status == 200) {
                console.log(request);
                console.log(request.status);
                try {
                    data = JSON.parse(request.responseText);
                }
                catch (e) {
                    err = e;
                }
            }
            else {
                err = new Error(`Error loading json ${request.status}`);
            }
            callback(err, data);
        };
        request.onerror = () => {
            retries--;
            if (retries > 0) {
                setTimeout(makeReq, 1000);
            }
            else {
                err = new Error(`Error loading json ${request.status}`);
                callback(err);
            }
        };
        request.send();
    };

    makeReq();
};

export default getJSON;
