when i execute this function
const stronaDyskusji = "Some_mediawiki_discussion_page_name";
async function sekcje() {
var zwrot;
const params = {
action: "parse",
page: stronaDyskusji,
prop: "sections",
};
const api = new mw.Api();
await api.get(params).done((data) => {
zwrot = data.parse["sections"];
});
return zwrot;
}
var PIT = sekcje()
console.log(PIT)
the console logs this kind of object.
Is there any way to get this array out of this [[PromiseResoult]]:
to for example other variable?
Async functions return promise. If you want to access the result directly you will need to either use await (when you make the sekcje function call) or use the "then" callback on the returned promise.
const PIT = await sekcje();
console.log(PIT);
But for the await to work you will need to put it inside an async function.