我的poauth2正在与服务器连接。现在,我需要发出API请求,并尝试关注Moya文档等。这是到目前为止的内容:
let requestClosure = { (endpoint: Endpoint, done:@escaping (Result<URLRequest,MoyaError>) -> ()) in
let request = try! self.appDelegate.oauth2.request(forURL: endpoint.urlRequest().url!)
// set up your request, e.g. `req.HTTPMethod = "POST"`
let task = self.appDelegate.oauth2.session.dataTask(with: request) { (data, response, error) -> Void in
DispatchQueue.main.async(execute: { () -> Void in
if error == nil {
result(data as NSData?, nil)
done(result)
} else {
result(nil, error as NSError?)
}
})
}.resume()
}
let cbProvider = MoyaProvider<CoinbaseService>(requestClosure: requestClosure)
此行给出了编译错误:
let requestClosure = { (endpoint: Endpoint, done:@escaping (Result<URLRequest,MoyaError>) -> ()) in
Generic type 'Result' specialized with too many type parameters (got 2, but expected 1)
但是,如果我删除第二个参数,则此行将无法编译:
MoyaProvider<CoinbaseService>(requestClosure: requestClosure)
这里的任何帮助都会很棒。