mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Split the web console into by-job files, add page tests and a docs-table test, plus docs
AI Assisted
This commit is contained in:
1 parent
699a827cae
commit
3edb4468a8
121 files changed
+25603
-20145
No files matched your search
@@ -0,0 +1,22 @@
|
||||
// Plan2Code Web Console - the page talking to its own server.
|
||||
//
|
||||
// Only defines.
|
||||
|
||||
// POST a JSON body; the status and parsed answer, or status 0 when the
|
||||
// server could not be reached.
|
||||
export async function postJson(url, body) {
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify(body || {}),
|
||||
});
|
||||
let answer = {};
|
||||
try {
|
||||
answer = await res.json();
|
||||
} catch {}
|
||||
return { status: res.status, body: answer };
|
||||
} catch {
|
||||
return { status: 0, body: {} };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user