The api service I was using was blocked in some regions, so now I need to send https requests through a proxy server. Can someone tell what function/library/something else I need to send a request through a proxy server?
This is my code:
let headers = [
"x-rapidapi-key": "<my key>",
"x-rapidapi-host": "weatherapi-com.p.rapidapi.com"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://weatherapi-com.p.rapidapi.com/forecast.json?q=\(latitude)%2C%20\(longitude)&days=\(daylyScrollLength)&lang=ru")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if let data, let weather = try? JSONDecoder().decode(WeatherForecastData.Data.self, from: data){
weatherData(weather)
}
})
dataTask.resume()