hi, i am trying to make my own user interface with dataviewjs. That’s my code :
const container = dv.container;
container.setAttribute('class', 'document--full-page');
const Title = dv.el('h1', 'Physique');
Title.style.fontSize = '70px';
const SubTitle = dv.el('h2', 'Cours :');
SubTitle.style.fontSize = '16px';
SubTitle.style.fontWeight = 'normal';
const Separator = dv.el('hr', '');
const load = dv.io.load("json.md")
container.appendChild(Title);
container.appendChild(SubTitle);
container.appendChild(Separator);
the output of dv.io.load(“json.md”) is
-
Promise {}
-
[[Prototype]]: Promise
-
[[PromiseState]]: “fulfilled”
-
[[PromiseResult]]: “My target content”
Things I have tried
i’ve tried to use then() method
this is what i’ve done :
const load = dv.io.load(“json.md”).then(data => {
console.log(data)
})
and it works ! data is the information i wanted. But i don’t know how to extract this value outside the then method. So my questions are :
- is there a way to extract variables from then() and use them in the script
- how to precise i want the value of [[PromiseResult]]
thanks for helping me