MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / httpRequest

Function httpRequest

webUi/scripts.js:75–95  ·  view source on GitHub ↗
(method, url, { async = true, body, headers = {}, onload, onerror } = {})

Source from the content-addressed store, hash-verified

73}
74
75function httpRequest(method, url, { async = true, body, headers = {}, onload, onerror } = {}) {
76 const xhr = new XMLHttpRequest();
77 if (typeof onload === "function") {
78 xhr.onload = () => onload(xhr);
79 }
80 xhr.onerror = () => {
81 if (typeof onerror === "function") {
82 onerror(xhr);
83 } else {
84 console.error("Network error or request failure.");
85 }
86 };
87 xhr.open(method, url, async);
88 Object.keys(headers).forEach((header) => xhr.setRequestHeader(header, headers[header]));
89 if (body !== undefined && body !== null) {
90 xhr.send(body);
91 } else {
92 xhr.send();
93 }
94 return xhr;
95}
96
97function isNullOrEmpty(value) {
98 return value === null || value === "";

Callers 10

WifiConfigFunction · 0.85
SDConfigFunction · 0.85
startUpdateFunction · 0.85
callOTAFunction · 0.85
logoutButtonFunction · 0.85
rebootButtonFunction · 0.85
systemInfoFunction · 0.85
listFilesButtonFunction · 0.85
renameFileFunction · 0.85
downloadDeleteButtonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected