async function METHOD()

in webui/js/blocky4.js [2:25]


async function METHOD(method = 'POST', url = '', data) {
    let payload = {
        method: method,
        mode: 'cors',
        cache: 'no-cache',
        credentials: 'same-origin',
        headers: data ? {
            'Content-Type': 'application/json'
        } : {},
        redirect: 'follow',
        referrerPolicy: 'no-referrer'
    }
    if (data) {
        payload.body = JSON.stringify(data);
    }
    try {
        const response = await fetch(url, payload).catch( (e) => {throw e});
        if (response.ok !== true) throw `HTTP Error ${response.status}: ${response.statusText}`
        let js = response.json();
        return js
    } catch (e) {
        alert(e);
    }
}