The validate()
operator checks that a valid HTTPURLResponse
was returned with a status code in the range of 200...299
and forwards along the Data
returned from the request.
let cancellable = URLSession.shared
.dataTaskPublisher(for: URL(string: "https://someurl.com/"))
.validate()
.sink { (response: Data) in
// Do something with your data
}