Làm thế nào để sử dụng chức năng TypeScript async/await và trả về các lời hứa mặc định typescript trong module js FS và gọi hàm khác khi lời hứa được giải quyết.Cách sử dụng Typescript Async/await với lời hứa trong Node JS FS Module
Tiếp theo là các mã:
if (value) {
tempValue = value;
fs.writeFile(FILE_TOKEN, value, WriteTokenFileResult);
}
function WriteTokenFileResult(err: any, data: any) {
if (err) {
console.log(err);
return false;
}
TOKEN = tempValue;
ReadGist(); // other FS read File call
};