Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm currently working with POST requests and I'm trying to POST data to postman. The data is being sent, but after I press the "send" button, it won't untap. What could be the reason behind it? This is my button view:

        Button(action: {
                loginManager.firstName = addFirstName
                loginManager.lastName = addLastName
                loginManager.emailAddress = addEmail
                loginManager.phoneNumber = addPhoneNumber
                loginManager.addNewUser()
        }) {
            ZStack {
            Text("Send")
            }
        }

And this is the section of the addNewUser function that sends the data to postman:

let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
            
            // Check for Error
            if let error = error {
                print("Error took place (error)")
                return
            }
     
            // Convert HTTP Response Data to a String
            if let data = data, let dataString = String(data: data, encoding: .utf8) {
                print("Response data string:
 (dataString)")
            }
    }
    task.resume()
    semaphore.wait()

Is there something that I'm missing? Thanks in advance!

question from:https://stackoverflow.com/questions/65874554/untap-button-after-sending-a-post-request

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.4k views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...