title: Get temperature of current location API swift
body: <p>Can anyone help me with this API code.  I got everything but one error fixed.</p>
  
  <p>Here is my code:</p>
  
  <pre><code> let APIUrl = NSURL(string:"https://api.openweathermap.org/data/2.5/weather?   lat=35&amp;lon=150&amp;appid=e7b2054dc37b1f464d912c00dd309595&amp;units=Metric")
   var request = URLRequest(url:APIUrl! as URL)
  
   let task = URLSession.shared.dataTask(with: request as URLRequest)
  
   guard let data = Data else {return}
  
   let decoder = JSONDecoder()
  
   let weatherData = try decoder.decode(MyWeather, from: data)
  
   let ggtemp = weatherData.main?.temp
      print(ggtemp, "THIS IS THE TEMP")
          DispatchQueue.main.async {
          tempDisplay.text = String (ggtemp) + " c"
       }
   }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/lomHR.png" rel="nofollow noreferrer">Image of error</a></p>
  
  <p>Once I fix the "let data = data" error, I get an error on the "let task = URLSesss..."</p>
  
  <p>Any help would be appreciated. Thanks in advance.</p>