URLSession integration
swift
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "https://api.apitube.io/v1/news/everything?limit=50&api_key=YOUR_API_KEY")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()