我无法从PromiseKit 4.0转换为PromiseKit 6.3。我正在尝试将此特定功能转换为新版本。我该怎么办?
func registerUser(_ email: String, givenName: String, familyName: String, password: String) -> Promise<JSON> {
let req = urlRequestForPath("/user/create/local/", parameters: nil, method: .POST) as! NSMutableURLRequest
let queryString = stringFromParameters(["email": email.lowercased() as AnyObject, "given_name": givenName as AnyObject, "family_name": familyName as AnyObject, "password": password as AnyObject, "client_id": oauthClientId as AnyObject])
req.httpBody = queryString.data(using: String.Encoding.utf8, allowLossyConversion: false)
return URLSession.shared.dataTask(with: req as URLRequest).then{(data: Data) -> JSON in
return try! JSON(data: data)
}
}
答案 0 :(得分:0)
它应该返回如下,
models.objects.all()