我正在做一个提出请求的演示应用Swift 2
程序HTTP
POST
。但是不明白为什么我的请求没有到达服务器。我正在使用Alamofire 3.0
, Xcode 7.2
, swift 2.0
. 我Alamofire
根据此链接安装了 pod :https ://github.com/Alamofire/Alamofire#requirements
我的字符串是
str = "{videos{title,videourl,imageurl}}"
这里我的代码是:
Alamofire.request(
.POST,
url,
parameters: Dictionary(),
encoding: .Custom({
(convertible, params) in
let mutableRequest = convertible.URLRequest.copy() as! NSMutableURLRequest
mutableRequest.setValue("application/graphql", forHTTPHeaderField: "Content-Type")
mutableRequest.HTTPBody = str.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
return (mutableRequest, nil)
}),
headers: nil
).responseJSON{
(JSON) -> Void in
if JSON.result.value != nil
{
print(JSON.result.value)
self.delegate.successReponse(JSON.result.value!, withType: type)
}
else
{
}
}
当我打印时JSON.result.value
,它显示如下:
Optional({
errors = (
{
}
);
})
我不明白为什么它没有到达服务器。