make a get request with alamofire, with parameters in swift

To make a GET request with parameters, you can use Alamofire's request(_:method:parameters:) method. Here's an example:

main.swift
import Alamofire

let parameters = ["foo": "bar", "baz": "qux"]
let url = "https://example.com/api"

AF.request(url, method: .get, parameters: parameters).responseJSON { response in
    debugPrint(response)
}
209 chars
9 lines

In this example, we're making a GET request to the specified URL with the parameters dictionary in the request. The responseJSON closure is called with the response from the server, which we're just printing to the console for debugging purposes.

Note that Alamofire automatically encodes the parameters as query parameters for GET requests. If you need to encode the parameters in a different way, you can use a custom encoding.

gistlibby LogSnag