我知道以前有人问过这个问题,但在我的情况下该怎么做呢?
import Stripe
class MyAPIClient: NSObject, STPCustomerEphemeralKeyProvider {
let baseURL = "https://api.stripe.com"
func createCustomerKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) {
let url = self.baseURL.appendingPathComponent("ephemeral_keys") /*1st error - 'appendingPathComponent' is unavailable: Use appendingPathComponent on URL instead.*/
var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)! /*2nd error - Cannot convert value of type 'String' to expected argument type 'URL'*/
urlComponents.queryItems = [URLQueryItem(name: "api_version", value: apiVersion)]
var request = URLRequest(url: urlComponents.url!)
request.httpMethod = "POST"
let task = URLSession.shared.dataTask(with: request, completionHandler: { (data, response, error) in
guard let response = response as? HTTPURLResponse,
response.statusCode == 200,
let data = data,
let json = ((try? JSONSerialization.jsonObject(with: data, options: []) as? [String : Any]) as [String : Any]??) else {
completion(nil, error)
return
}
completion(json, nil)
})
task.resume()
}
}
i)我正在使用
A)快速
B)火库
c) nodejs -我应该使用其他东西而不是node js吗?
另外,我还应该做哪些其他修改?欢迎所有其他建议。
发布于 2021-01-30 12:19:38
苹果公司从String
中移除路径修改API已经很长时间了。
您必须创建一个URL,这就是错误所暗示的
let baseURL = URL(string: "https://api.stripe.com")!
https://stackoverflow.com/questions/65967831
复制相似问题