I am very new to Xcode and trying to fetch data from my WordPress website in SwiftUI using rest api. I have got code from internet , I have installed these pod's
pod 'SwiftyJSON'
pod 'Alamofire'
pod 'SDWebImage'
Imported all pods in homeController and using this code to fetch data.
Alamofire.request("\(urlPage)\(page)").responseJSON { response in
if let data = response.result.value {
let json2 = JSON(data)
self.moreDataNum = json2["count"].intValue
if self.dataArray?.isEmpty == false {
self.dataArray.append(contentsOf: json2["posts"].arrayValue)
self.collectionView.reloadData()
// ...
I am getting this error..
please help me ..
if you use latest version of alamofire 5.5.0 then use below code :---
let musicAPI = "https://staging.mywowmemories.com/api/get-background-music"
AF.request(musicAPI, method: .get, parameters: nil, encoding: URLEncoding.default, headers: nil).responseJSON { (response) in
if let result = response.value as? NSDictionary {
}
}