I want to POST to a website first and then GET another website for the data.
And change the key in the POST, and keep doing this in a for-loop for 5 times to get different data.
However, the program always first run the POST for 5 times and secondly run the GET for another 5 times, which makes me get the same data.
Here is the code:
for i in 1...5{
let postData: Parameters = ["key": "\(i)"]
Alamofire.request(" POST Website", method: HTTPMethod.post, parameters: postData, encoding: URLEncoding.default, headers: self.headers).response(completionHandler: { (ressponse) in
Alamofire.request(" GET Website ", method: HTTPMethod.get, headers: self.headers).response(completionHandler: { (response) in
// Get Data
})
})
}
How can I fix this?
Thanks