
function toJSON(dataStr) {
    return new Promise((res, rej) => {
        res(JSON.parse(dataStr));
    });
}

function queryGet(url) {
    return new Promise((res, rej) => {
        var req = new XMLHttpRequest();
        req.onreadystatechange = function() {
            if (req.readyState === 4) {
                if (Math.floor(req.status / 100) === 2) {
                    res(req.responseText);
                } else {
                    rej(req.statusText);
                }
            }
        };
        req.open("GET", url, true);
        req.send();
    });
}

