Impl HTTPCRUD db

master
Bel LaPointe 2021-02-27 13:06:59 -06:00
parent c724f0ee0b
commit 3cd47b56cf
1 changed files with 7 additions and 9 deletions

View File

@ -1464,7 +1464,6 @@
do(method, key, data)
{
var result = null;
console.log("DO:", this.toPath(key), method, data);
$.ajax({
url: this.toPath(key),
type: method,
@ -1474,17 +1473,15 @@
processData: false,
contentType: "application/json",
success: (data, statusText, jqXHR) => {
console.log(method, key, ": parsing: ", data);
if (data)
result = JSON.parse("" + data);
console.log("parsed: ", result)
if (! data)
data = "null";
result = data;
},
error: (jqXHR, statusText, err) => {
if (jqXHR.status > 410)
throw new Error("unexpected status: " + statusText + ": " + err);
},
});
//console.log("DID:", this.toPath(key), method, data, result);
return result;
}
@ -1505,7 +1502,8 @@
forEach(foo)
{
var result = this.do("GET", "", null);
var result = this.get("");
result = JSON.parse(result);
if (! result)
result = [];
result.forEach((k) => {
@ -1577,8 +1575,8 @@
}
globalStorage = new MultiDatabase(
new NamespacedDatabase("A", new Local()),
//new NamespacedDatabase("8", new HTTPCRUD()),
new NamespacedDatabase("1", new HTTPCRUD()),
//new NamespacedDatabase("A", new Local()),
//new NamespacedDatabase("B", new Local()),
//new Bomber(),
);