I am trying to get JSON data from the API & I want to print it on the terminal to check whether I am receiving data on my terminal or not but I am getting this error. I am currently using Swift 5 .
import UIKit
import Alamofire
typealias JSON = [String: Any]
class NetworkingService {
static let shared = NetworkingService()
private init() {}
func getPeople(completion: () -> Void) {
AF.request("https://launchlibrary.net/1.4/launchstatus").responseJSON{ (response) in
if let json = response.result.value as? JSON { // here I am getting error
print(json)
}
}
}
}
Replace your request completion block with:
switch response.result {
case let .success(value):
print(value)
case let .failure(error):
print(error)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With