aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/utils.js
blob: db9405c84a017129132c718338d4b2176ca90f40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export function createCurlCommand(subCommand, data) {
    let full = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
    return `curl --request PUT \\\n  --url ${full}/api${subCommand} \\\n  ` +
        `--header 'content-type: application/json' \\\n  --data '${JSON.stringify(data)}'`;
}

export function objectToQueryString(obj) {
    let str = [];
    for (let p in obj)
        if (obj.hasOwnProperty(p)) {
            str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
        }
    return str.join("&");
}