Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let parameters = "{"user_Name" : "(user)", "user_Password" : "(psw)"}"
- let url = URL(string:"http://192.168.2.127:8080/restapi/login/user/shop")!
- var request = URLRequest(url:url)
- request.addValue("application/json", forHTTPHeaderField: "Content-Type")
- request.httpMethod = "POST"
- request.httpBody = parameters.data(using: String.Encoding.utf8)
- print(request.httpBody)
- let session = URLSession.shared.dataTask(with: request){ (data,response,error) in
- if let response = response {
- print(response)
- }
- if let data = data {
- do{
- self.result = try? JSONDecoder().decode(LoginJson.self, from: data)
- //guard let blog = try? JSONDecoder().decode(Blog.self, from: data) else {
- if self.result?.status_code == "200" {
- self.performSegue(withIdentifier: "homePage", sender: self)
- }
- else{
- DispatchQueue.main.async {
- self.messageLabel.isHidden = false
- self.messageLabel.text = "please enter Valid Email and Password!"
- }
- }
- }catch let err{
- print(err.localizedDescription)
- }
- }
- }
- session.resume()
Add Comment
Please, Sign In to add comment