|
| 1 | +<html> |
| 2 | +<head> |
| 3 | + <title>Minimal Debugging UI</title> |
| 4 | + <link rel="stylesheet" href="https://the.missing.style/v1.0.6/missing.min.css"> |
| 5 | + |
| 6 | + <script src="https://unpkg.com/mithril/mithril.js"></script> |
| 7 | +</head> |
| 8 | +<body> |
| 9 | + <script> |
| 10 | +var root = document.body |
| 11 | + |
| 12 | +const server = "http://localhost:3000/jsonrpc" |
| 13 | +const token = "85b2ae37-0be4-4faa-b1f0-d02189a31cfa" |
| 14 | + |
| 15 | +async function callMethod(method, params) { |
| 16 | + const obj = { |
| 17 | + jsonrpc: "2.0", |
| 18 | + method: method, |
| 19 | + id: "1", |
| 20 | + params: [token, params], |
| 21 | + } |
| 22 | + |
| 23 | + const response = await fetch(server, { |
| 24 | + method: "POST", // *GET, POST, PUT, DELETE, etc. |
| 25 | + mode: "cors", // no-cors, *cors, same-origin |
| 26 | + cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached |
| 27 | + credentials: "same-origin", // include, *same-origin, omit |
| 28 | + headers: { |
| 29 | + "Content-Type": "application/json", |
| 30 | + // 'Content-Type': 'application/x-www-form-urlencoded', |
| 31 | + }, |
| 32 | + redirect: "follow", // manual, *follow, error |
| 33 | + referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url |
| 34 | + body: JSON.stringify(obj), // body data type must match "Content-Type" header |
| 35 | + }) |
| 36 | + return response.json() // parses JSON response into native JavaScript objects |
| 37 | +} |
| 38 | + |
| 39 | +callMethod("examples.getStateName", [12]).then(data => { |
| 40 | + console.log(data) // JSON data parsed by `data.json()` call |
| 41 | +}) |
| 42 | + |
| 43 | +callMethod("ssb.post", { |
| 44 | + identity: "@fu9wRz7+UwjDcvW6TZrvbNDT0cEPgWBh/ZZq5dKGEyY=.ed25519", |
| 45 | + content: { |
| 46 | + text: `Now it will work`, |
| 47 | + root: "%sUJg+n7aIiDXPWQPrEMi4Tg82KhyF4gpI0TaQt0Z8Vc=.sha256" |
| 48 | + } |
| 49 | +}) |
| 50 | +.then(data => { |
| 51 | + console.log(data) |
| 52 | +}) |
| 53 | +.catch(err => { |
| 54 | + console.log("error", err) |
| 55 | +}) |
| 56 | + |
| 57 | +// callMethod("ssb.timeline.public", {identity: "@fu9wRz7+UwjDcvW6TZrvbNDT0cEPgWBh/ZZq5dKGEyY=.ed25519"}) |
| 58 | +// .then(data => { |
| 59 | +// console.log(data) |
| 60 | +// }) |
| 61 | +// .catch(err => { |
| 62 | +// console.log("error", err) |
| 63 | +// }) |
| 64 | + |
| 65 | + |
| 66 | +/* Live reload */ |
| 67 | +document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + |
| 68 | + ':35729/livereload.js?snipver=1"></' + 'script>') |
| 69 | + </script> |
| 70 | + |
| 71 | +</body> |
| 72 | +</html> |
0 commit comments