title: How do you pass a value to an API in Swift?
body: <p>I am pretty much a beginner in Swift and I am trying to pass a value to make a call to an API with the value being from an input field. 
  The API is given below. How do I write code to pass value for ZIP_CODE from a text field?</p>
  
  <p><a href="https://iaspub.epa.gov/enviro/efservice/getEnvirofactsUVDAILY/ZIP/ZIP_CODE/JSON" rel="nofollow noreferrer">https://iaspub.epa.gov/enviro/efservice/getEnvirofactsUVDAILY/ZIP/ZIP_CODE/JSON</a></p>
  
  <pre><code>@IBOutlet var zipLabel: UILabel!
  @IBOutlet var zipInput: UITextField!
  @IBOutlet var jsondataLabel: UILabel!
  
  override func viewDidLoad() {
      super.viewDidLoad()
      getJSON()      
  }
  
  @IBAction func btnAction() {
      zipLabel.text = zipInput.text
  }
  
  func getJSON(){
      let url = NSURL(string :"https://iaspub.epa.gov/enviro/efservice/getEnvirofactsUVDAILY/ZIP/10001/JSON")
      let request = URLRequest(url: url as! URL )
      let config = URLSessionConfiguration.default
      let session = URLSession(configuration: config)
  
      let task = session.dataTask(with: request){(data, response, error ) -&gt; Void in
          if error == nil{
              DispatchQueue.main.async(execute: {
                  let jsondata = JSON(data : data!)
  
                  print(jsondata)
                  print("-----")
                  print(jsondata[0]["UV_INDEX"])
  
                  let result =  jsondata[0]["UV_INDEX"].stringValue
  
                  self.jsondataLabel.text = result
              })
          }else{
              print("There was an error")    
          }
      }
      task.resume()
  }
  </code></pre>