I do not understand, how I can implement a RapidApi in a Swift Project, what am I doing wrong?
import Foundation
let headers = [
"x-rapidapi-host": "community-open-weather-map.p.rapidapi.com",
"x-rapidapi-key": "[your rapidapi key]"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk")! 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 (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
how do I have to wrap this, so it works?