I would avoid naming them, by doing the following:
functiongetAllFooBar(){// find smart_collectionsconstfoos=apiCall('foo').itemsconstbars=[]// for every foo valuefor(constfoooffoos){lettoken=undefineddo{// undefined skips key in JSON stringificationconstbarResponse=apiCall('bar',{...foo,token})bars.push(...barResponse.items)token=barResponse.nextPageToken}while(token)}}
Usually I would abstract such a behavior that can probably be used for multiple paths of the API into a business-logic-indifferent function:
A software engineer interested in solving real problems, developer productivity & learning languages for fun. Primarily working on Node.js, React & databases. Current Interest: Rustlang
A software engineer interested in solving real problems, developer productivity & learning languages for fun. Primarily working on Node.js, React & databases. Current Interest: Rustlang
I would avoid naming them, by doing the following:
Usually I would abstract such a behavior that can probably be used for multiple paths of the API into a business-logic-indifferent function:
Thanks Mihail. This looks good.
I stopped using do-while for quite some time. This looks to a very good use case. Thanks :)
I wish it let me do
while (token = res.newToken)
, butres
goes out of scope there. Too bad for JS spec.Yeah that wouldn't work in that case.