안녕하세요.
웹한글 기안기 API 는 Promise 객체를 반환하지 않기 때문에 await 형식으로 호출할 수 없습니다.
callback 방식으로 호출하여 순서대로 동작하도록 작업을 하거나,
Promise 객체를 반환하도록 추가 구현을 하여 await 형식으로 호출을 해주어야 할것 같습니다.
callback 방식
Ctrl.Insert(file1, "HWP", function() {
Ctrl.Insert(file2, "HWP", function() {
Ctrl.Insert(file3, "HWP", function() {
...
}, null);
}, null);
}, null);
Promise 구현
function Insert(file) {
var a = new Promise((resolve, reject) => {
HwpCtrl.Insert(file, "HWP", "", function(res) {
resolve(res);
});
});
return a;
}
Insert(file1).then(
() => Insert(file2)
).then(
() => Insert(file3)
).then(
() => Insert(file4)
)
or
await Insert(file1);
await Insert(file2);
await Insert(file3);
await Insert(file4);