This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy the function below to use in your scripts. | |
function createWidget() { | |
const widget = new ListWidget() | |
const wrap = (view, isWidget) => { | |
let wrapped | |
const wrapWith = (key, exec) => [key, (...args) => (exec(...args), wrapped)] | |
wrapped = Object.fromEntries(Object.keys(view).map(key => { | |
if (typeof view[key] === "function") { | |
if (key.startsWith("add")) return wrapWith(key, (...args) => { | |
let cb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: green; icon-glyph: file-code; | |
module.exports = { | |
post: async ({ url, body, headers = {} }) => { | |
const request = new Request(url); | |
request.body = JSON.stringify(body); | |
request.method = methods.post; | |
request.headers = { | |
...defaultHeaders, |