5

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)
            }
        } 
    }
}
LuLuGaGa
  • 13,089
  • 6
  • 49
  • 57
Eliza
  • 51
  • 1
  • 5

1 Answers1

14

Replace your request completion block with:

switch response.result {
case let .success(value):
    print(value)
case let .failure(error):
    print(error)
}
Yonat
  • 4,382
  • 2
  • 28
  • 37