'Can you help me debug my code. Image view and UILabel are not updating. JSON Alamofire request is successful

import UIKit import SwiftyJSON
import Alamofire
import Kingfisher

class ViewController: UIViewController {

@IBOutlet weak var memeImage: UIImageView!
@IBOutlet weak var bottomLabel: UILabel!
@IBOutlet weak var topText: UILabel!

@IBAction func generateMeme(_ sender: UIButton) {
    getRandomMeme(url: APIURL)
}

override func viewDidLoad() {
    
    
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}


let APIURL = "https://api.imgflip.com/get_memes"


func getRandomMeme(url : String) {
    Alamofire.request(url, method: .get).responseJSON{ [self] response in
        if response.result.isSuccess{
            print("Success")
            
            let memeJSON : JSON = JSON(response.result.value!)
            
            updateMeme(json: memeJSON)
            print(memeJSON)
            
            
        }else {
            print("Error \(response.result.error!)")
            
        }
        
    } }



func updateMeme(json: JSON) {
    
    let url = URL(string: json["data"]["memes"]["url"].stringValue)
    memeImage.kf.setImage(with: url)

    bottomLabel.text = json["data"]["memes"]["name"].stringValue
    
} }

// Here are the results from the API

Success { "data" : { "memes" : [ { "id" : "181913649", "height" : 1200, "width" : 1200, "url" : "https://i.imgflip.com/30b1gx.jpg", "name" : "Drake Hotline Bling", "box_count" : 2 }

api


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source