I'm using PromiseKit in my project and I need to do batch/multiple calls to the API and wait for all responses. Any ideas how to do this? I'm pretty new to PromiseKit, and didn't find anything regarding this on their Github (probably didn't see or understand it)
What I'm trying at the moment and failing is:
let ids = [1, 2, 3, 4, 5]
firstly {
getURLPathsFor(ids) // maybe I'm doing this wrong - this returns a Promise<[String]>
}.thenMap { url in
ApiManager.shared.request(url, method: .delete)
}.done { _ in
seal.fulfill(())
}.catch { error in
seal.reject(error)
}
func getURLPathsFor(_ ids: [UInt]) -> Promise<[String]> {
let path = "/somePath"
var URLs = [String]()
return Promise { seal in
ids.forEach { uid in
AppConfigManager.shared.getApiUrl(path: path, uid).done { url in
URLs.append(url)
seal.fulfill(URLs)
}.catch { error in
seal.reject(error)
}
}
}
}
Any help would be great, really stuck with this one.