解码Alamofire响应(无法复制邮递员)

时间:2020-04-10 22:15:32

标签: json http encoding postman alamofire

我正在使用Alamofire制作HTTP GET方法,如下所示:

AF.request("myURL", method: .get, parameters: payload, encoding: URLEncoding.default).responseData { response in
    switch response.result {
    case .success(let value):
        print(JSON(value))

    case .failure(let error):
        print(error)
    }
}

当我在Postman中进行GET时,会收到如下响应:

('{
    "OK": true,
    "token": "some string"
}',
200)

但是,当我尝试在我的iOS项目中获得该响应时,无法以JSON格式(我正在使用SwiftyJSON)来获取必要的数据,但我却得到了null 。我需要如何处理Alamofire通话才能获得与邮递员相同的答复?

0 个答案:

没有答案