Horje
Swift REST Api Call Code Example
Swift REST Api Call
let params = ["username":"john", "password":"123456"] as Dictionary<String, String>

var request = URLRequest(url: URL(string: "http://localhost:8080/api/1/login")!)
request.httpMethod = "POST"
request.httpBody = try? JSONSerialization.data(withJSONObject: params, options: [])
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

let session = URLSession.shared
let task = session.dataTask(with: request, completionHandler: { data, response, error -> Void in
    print(response!)
    do {
        let json = try JSONSerialization.jsonObject(with: data!) as! Dictionary<String, AnyObject>
        print(json)
    } catch {
        print("error")
    }
})

task.resume()




Shell

Related
install packages with pip from python Code Example install packages with pip from python Code Example
git fetch upstream Code Example git fetch upstream Code Example
remove pod and install again Code Example remove pod and install again Code Example
linux backup command line Code Example linux backup command line Code Example
download docker linux Code Example download docker linux Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12