Reputation: 1169
I am trying to use RxAlamofire for Reactive requests. There is a method for creating POST
request with -
public func request(_ method: Alamofire.HTTPMethod,
_ url: URLConvertible,
parameters: [String: Any]? = nil,
encoding: ParameterEncoding = URLEncoding.default,
headers: [String: String]? = nil
)
But I cannot pass an Array [[String : Any]]
to the parameters for obvious reasons. So how do I create a request with this array as parameters?
Being more specific, I can pass
let student = ["firstName":"Mayur", "lastName":"Deshmukh"]
as a parameter because it is of type [String : Any]
But I cannot pass array like
let students = [["firstName":"Mayur", "lastName":"Deshmukh"],
["firstName":"Kaustubh", "lastName":"Deshmukh"]]
As now the type of students is [[String : Any]]
So does Alamofire or RxAlamofire have any handy method for creating requests with JSON Array as parameter? Or do we have to take a harder way?
Upvotes: 0
Views: 651
Reputation: 2321
It's a bit unclear what you're trying to do. Do you have an array of dictionaries that you want to pass as a single dictionary for the query params? If so just combine them all via reduce
using something like shown here (for combining two dictionaries)
https://stackoverflow.com/a/26728685/2326892
If you mean something else it's not clear what that would be. Perhaps you can clarify.
Upvotes: -1