Demo: poner JSON en <details>

This commit is contained in:
Cat /dev/Nulo 2021-10-12 19:38:51 -03:00
parent 396a5a5880
commit 178d3474b8

View file

@ -23,6 +23,11 @@ function clear(el: Node) {
}
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 codeEl = document.createElement("code");
if (typeof object === "string") {
@ -33,7 +38,8 @@ function objectToDom(object: any) {
codeEl.append(object);
}
preEl.append(codeEl);
return preEl;
detailsEl.append(preEl);
return detailsEl;
}
async function showResponse(statusEl: Element | null, promise: Promise<any>) {