1
API와 상호 작용할 코드를 작성 중입니다. API를 사용하려면 나머지 요청에 사용하는 세션 키를 가져와야합니다. 그러면 세션 키는 잠시 동안 코드를 재실행 할 준비를해야합니다.코드 작업 흐름 설계
코드 자체는 코드 흐름을 디자인하는 방법에 대한 질문부터 관련성이 없으며 API도 아닙니다. 최선의 방법을 찾고 있습니다.
function getResult {
data = foobar
return getData(data, callback)
}
function getData(data, callback) {
*building query (including the session-key) and getting data via http*
if error == noauth
auth()
// What should happen here, I need to rerun the query
else
callback(result)
}
function auth {
data = foobar
getData(data, callback(?))
// it returns a session-key to use
//What should happen here?
}