0

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?

Mayur Deshmukh
  • 1,169
  • 10
  • 25

1 Answers1

-1

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.

SlashDevSlashGnoll
  • 2,141
  • 1
  • 12
  • 15
  • If you are unsure of what the question is, you can add a comment to a question instead of adding irrelevant answer. It has nothing to do with reducing. – Mayur Deshmukh Apr 26 '18 at 12:31