helpers.js
// Returns err if an error occured, or null if successful.
Returns err if an error occured, or null if successful.
Returns err if an error occured or null if successful .
async function exec(sreq, item) {
    try {
        let res;
        if (item) {
            res = await fetch(sreq, {
                method: "POST",
                headers: {"Content-Type": "application/json"},
                body: JSON.stringify(item),
            });
        } else {
            res = await fetch(sreq, {
                method: "POST",
            });
        }
        if (!res.ok) {
            let s = await res.text();
            let err = new Error(s);
            err.status = res.status;
            return err;
        }
        return null;
    } catch(err) {
        return err;
    }
}
async function exec ( sreq , item ) { try { let res ; if ( item ) { res = await fetch ( sreq , { method : "POST" , headers : { "Content-Type" : "application/json" } , body : JSON . stringify ( item ) , } ) ; } else { res = await fetch ( sreq , { method : "POST" , } ) ; } if ( ! res . ok ) { let s = await res . text ( ) ; let err = new Error ( s ) ; err . status = res . status ; return err ; } return null ; } catch ( err ) { return err ; } }
Returns err if an error occured, or null if successful.
Returns err if an error occured or null if successful .