서로 의존하는 8 개의 콜백이 있습니다. 내 아이디어 은 더 읽기 쉬운 프로세스를 가지고 있지만이 문제를 어떻게 처리해야하는지 이해할 수 없습니다.Nodejs : 여러 약속 콜백 다루기 (콜백 지옥)
내 콜백 지옥의 예는 다음과 같습니다
return new Promise(function (resolve, reject) {
client.command("Command")
.then(function() {
client.command(command1)
.then(function() {
client.command(command2)
.then(function() {
client.command(command3)
.then(function() {
client.command(command4)
.then(function() {
client.command(command5)
.then(function() {
client.command(command6)
.then(function() {
client.command(command7)
.then(function() {
client.command(issue)
.then(function() {
client.command(command8)
.then(function (result) {
resolve(result.substring(0, 6));
});
});
});
});
});
});
});
});
});
});
});
사람이 처리하는 방법을 알고?
의 가능한 속는 https://stackoverflow.com/questions/22539815/arent-promises-just-callbacks – JohnnyHK