Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ankittlp/b3c063c6c05354f64a1ca1e82818f025 to your computer and use it in GitHub Desktop.
Save ankittlp/b3c063c6c05354f64a1ca1e82818f025 to your computer and use it in GitHub Desktop.
URLSessionDataTaskPublisher_basic
let urlSessionPublisher = URLSession.shared.dataTaskPublisher(for: url)//.map { $0.data }
let subscription = urlSessionPublisher.sink(receiveCompletion: { (error) in
print("error \(error)")
}) { (data,response) in
print("Data \(String(data: data, encoding: .utf8)) - Response - \(response)" )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment