Demo: poner JSON en <details>
This commit is contained in:
parent
396a5a5880
commit
178d3474b8
1 changed files with 7 additions and 1 deletions
|
@ -23,6 +23,11 @@ function clear(el: Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function objectToDom(object: any) {
|
function objectToDom(object: any) {
|
||||||
|
const detailsEl = document.createElement("details");
|
||||||
|
const summaryEl = document.createElement("summary");
|
||||||
|
summaryEl.append("JSON");
|
||||||
|
detailsEl.open = true;
|
||||||
|
detailsEl.append(summaryEl);
|
||||||
const preEl = document.createElement("pre");
|
const preEl = document.createElement("pre");
|
||||||
const codeEl = document.createElement("code");
|
const codeEl = document.createElement("code");
|
||||||
if (typeof object === "string") {
|
if (typeof object === "string") {
|
||||||
|
@ -33,7 +38,8 @@ function objectToDom(object: any) {
|
||||||
codeEl.append(object);
|
codeEl.append(object);
|
||||||
}
|
}
|
||||||
preEl.append(codeEl);
|
preEl.append(codeEl);
|
||||||
return preEl;
|
detailsEl.append(preEl);
|
||||||
|
return detailsEl;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showResponse(statusEl: Element | null, promise: Promise<any>) {
|
async function showResponse(statusEl: Element | null, promise: Promise<any>) {
|
||||||
|
|
Loading…
Reference in a new issue