2017-12-23 23 views
-3
getStore().then((store) => { 
    buildRates().then((rates) => { 
    let newStore = store; 
    newStore.rates = rates; 
    setStore(newStore).then((res) => { 
     // callback 
     cb(null, res); 
    }) 
    }) 
}); 

async/await 구문에이 문제가 발생했습니다. 나는 await buildRates()자바 스크립트를 설정할 객체 속성을 기다리는 중

어떤 아이디어가에서 store.rates에서 객체없이

let store = await getStore(); 
store.rates = await buildRates(); 
setStore(store).then((res) => { 
    // callback 
    cb(null, res); 
}); 

... setStore 원래 목적은 await getStore()에서 반환 된 사용합니다 ...이 같은 기다리고로 쓸 때?

+2

재생산 할 수 없음 : https://jsfiddle.net/kb51h92y/ – JJJ

+2

'buildRates'가 더 이상 약속을 반환하지 않거나 약속이 예상치 못한 값으로 해결되었다고 가정합니다. – Sumurai8

답변

0

해결되었습니다. 문제는 buildRates()이 아니기 때문에 적절한 약속이 아닙니다.

+8

그래서 문제는 코드에 표시되지 않았습니다. 나는이 질문을 삭제할 것을 제안 할 것이다. 그 이유는 미래의 참고 자료로서 다른 사람들에게 아무런 쓸모가 없기 때문이다. – jfriend00

+0

sry를 삭제할 수 없습니다 : S – smokerockspunchcops