【发布时间】:2020-09-16 13:43:14
【问题描述】:
我使用 Alamofire 在 Swift 中联网,并没有为请求中的参数参数补充信息。我得到的结果很好。有谁知道参数参数的用途以及我应该何时补充信息?
let editedFlowerName = flowerName.replacingOccurrences(of: " ", with: "%20", options: .literal, range: nil)
let url = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro&explaintext&redirects=1&indexpageids"
guard let wikiURL = URL(string: "\(url)&titles=\(editedFlowerName)") else {fatalError("Error creating url")}
//print(wikiURL)
AF.request(wikiURL, method: .get).validate()
.responseJSON { (response) in
let json = JSON(value)
print(json)
}
【问题讨论】:
标签: swift networking alamofire