1class RestClient { 2 getDefaultJsonHeaders() { return { 3 'Accept': 'application/json', 4 'Content-Type': 'application/json', 5 }} 6 getJsonHeaders(headers=null) { return (headers) ? {...this.getDefaultJsonHeaders(), ...headers} : this.getDefaultJsonHeaders() } 7 async get(url, headers) { 8 const data = { 9 method: 'GET', 10 headers: this.getJsonHeaders(headers) 11 } 12 console.debug(url) 13 console.debug(data) 14 const res = await fetch(url, data) 15 console.debug(res) 16 const json = await res.json() 17 console.debug(json) 18 console.debug(JSON.stringify(json)) 19 return json 20 } 21 async post(url, headers, params) { 22 const body = JSON.stringify(params); 23 console.debug(url) 24 const data = {} 25 data.method = 'POST' 26 data.headers = this.getJsonHeaders(headers) 27 if (params) { data.body = body } 28 console.debug(params) 29 console.debug(data) 30 const res = await fetch(url, data) 31 console.debug(res) 32 const json = await res.json() 33 console.debug(json) 34 console.debug(JSON.stringify(json)) 35 return json 36 } 37}
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.