title: GET data from a website using JSON format
body: <p>I want to get data from the website mentioned in the code but I have an error and I didn't khow what I should do to solve it.
  Is there any one who can help me?
  Thank you</p>
  
  <p>these is the code that I used</p>
  
  <pre><code> @IBAction func onGetTapped(_ sender: Any) {
     guard let url = URL(string: "http://gpsforanimal.herokuapp.com/") else { return }
   let session = URLSession.shared
   session.dataTask(with: url) { (data, response, error) in
                  if let response = response {
                      print(response)
                  }
                  if let data = data {
                      print(data)
                      do {
                          let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String:Any]
                          print(json)
                      } catch {
                          print(error)
                      }
  
                  }
              }.resume()
          }
  </code></pre>
  
  <p>and I get this</p>
  
  <pre><code>&lt;NSHTTPURLResponse: 0x16d47ac0&gt; { URL: http://gpsforanimal.herokuapp.com/ } { status code: 200, headers {
      "Cache-Control" = "max-age=0, private, must-revalidate";
      Connection = "keep-alive";
      "Content-Length" = 17536;
      "Content-Type" = "text/html; charset=utf-8";
      Date = "Thu, 05 Jul 2018 21:57:30 GMT";
      Etag = "W/\"cde6bf7e5688b2395a936b5785c715c4\"";
      Server = "WEBrick/1.3.1 (Ruby/2.2.6/2016-11-15)";
      "Set-Cookie" = "_GPS_session=MkZTb1NWQmp1QnA5MXFpUHQ3Wk1NdHV6Vm5ESjNGR1M5cC9jMUkxRTFVQXFuU1VTWko0R2F2a29WV3hNMzczcTAzVjB2TmpBTG5QbGFwcUVObnFHTEp5T0J6NWlFNXNBZ1ZJT1M4R3ZxRWthTzV4RUswalk3eDlrME1mc09KRGZlYzhLaGwxSlh1aGVXcDlPaFF4Vi9RPT0tLUNzNHpzUlVHSXFkZ3czZThyZU9ZMlE9PQ%3D%3D--c9fbcde23b38905f956d4a139629c710565d1015; path=/; HttpOnly";
      Via = "1.1 vegur";
      "X-Content-Type-Options" = nosniff;
      "X-Frame-Options" = SAMEORIGIN;
      "X-Request-Id" = "c2c9432e-37dd-4f44-9d10-62314f2c8ebc";
      "X-Runtime" = "0.040508";
      "X-Xss-Protection" = "1; mode=block";
  } }
  17536 bytes
  Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x16d63c60 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
  </code></pre>