I'm using Moya 11.0.2 for iOS 12 app but it's not setting the headers value for the request. The request only contains the default HTTP headers, not the custom ones.
Still not working for Moya 12.0.0.beta.1.
It works well on iOS 11.
extension OwnService : TargetType {
var headers: [String : String]? {
switch self {
case .checkKey(let params):
return ["Content-Type": "application/json", "custom-key" : params.key]
}
}
var method: Moya.Method {
switch self {
case .checkKey:
return .post
}
}
var task: Task {
switch self {
case .checkKey:
return .requestPlain
}
}
}
let provider = MoyaProvider<OwnService >(plugins: [NetworkLoggerPlugin(verbose: true, responseDataFormatter: ServerProxyConstants.JSONResponseDataFormatter)])
provider.request(.checkKey(key: "custom key")) { (result) in
// Custom code here
}
Sorry, the problem was that my custom key ended with a \n character, so the provider excluded it.
Most helpful comment
Sorry, the problem was that my custom key ended with a \n character, so the provider excluded it.