Alamofire 5是否有新错误?因为这上次没有遇到错误。下面是完成的代码。任何使用Alamofire的人都面对过吗?
import Foundation
import Alamofire
class MyAppService {
static let shared = MyAppService()
let url = "http://127.0.0.1:5000"
private init() { }
func getCurrentUser(_ completion: @escaping (SomeRequest?) -> ()) {
let path = "/somePath"
AF.request("\(url)\(path)").responseData { response in
if let data = response.result.value { //error shown here (Value of type 'Result<Data, AFError>' has no member 'value')
let contact = try? SomeRequest(protobuf: data)
completion(contact)
}
completion(nil)
}
}
}
答案 0 :(得分:5)
您必须如下提取FROM node:10.7.0-alpine AS base
ENV CHROME_BIN="/usr/bin/chromium-browser" \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
RUN set -x \
&& apk update \
&& apk upgrade \
&& apk add --no-cache \
udev \
ttf-freefont \
chromium \
&& npm install puppeteer@1.10.0
RUN mkdir -p /app
WORKDIR /app
COPY ./ /app/
ENTRYPOINT ["npm"]
CMD ["start"]
值,
result
答案 1 :(得分:1)
您还可以通过这种方式提取响应
AF.request(url, method: HTTPMethod.get, parameters: param as? Parameters)
.responseJSON { response in
if let JSON = response.value {
if response.response?.statusCode == 200{
completionHandler(JSON as AnyObject?, nil)
}else if(response.response?.statusCode == 401){
completionHandler(JSON as AnyObject?, nil)
}
}
else{
if response.response?.statusCode == 401 {
SVProgressHUD.showInfo(withStatus: "Request timed out.")
}
else {
completionHandler(nil,response.error as NSError?)
}
}
}