PageSourceSearch

https://scribble.com/scribby/lib/resty.js

js scribble.com collected 2026-10-02 08:11:36 UTC 1,568 bytes, 51 lines download raw bytes

1/*
2    handles rest save/read ... functional, but kind of experimental 
3
4    https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
5*/
6
7class Resty {
8    static any(url = '', method = 'GET', data = null) {
9        if (url.startsWith('http:')) url = 'https:' + url.substr(5);
10    // Default options are marked with *
11        var args = {
12            method: method, // *GET, POST, PUT, DELETE, etc.
13            mode: "cors", // no-cors, cors, *same-origin
14            cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
15            credentials: "same-origin", // include, *same-origin, omit
16            headers: {
17                "Content-Type": "application/json",
18            },
19            redirect: "follow", // manual, *follow, error
20            referrer: "no-referrer", // no-referrer, *client
21        };
22        if (data) args.body = JSON.stringify(data);
23        return fetch(url, args);
24    }
25
26    static get(url = '') {
27        return Resty.any(url);
28    }
29    static post(url = '', data = {}) {
30        return Resty.any(url, 'POST', data);
31    }
32    static put(url = '', data = {}) {
33        return Resty.any(url, 'PUT', data);
34    }
35    static delete(url = '') {
36        return Resty.any(url, 'DELETE');
37    }
38}
39
40/* 
41
42some potential places to store json.  functionality tested with jsonblob.com -- it is pretty great!
43
44https://jsonblob.com/api
45http://myjson.com/api
46https://jsonbin.io/
47https://cloud.google.com/storage/docs/json_api/
48https://www.npoint.io/
49https://developer.openstack.org/api-ref/object-store/
50
51*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.