Also, why can't I implement throwsin my function when it is throwing ? If you declare your connect as throws, it should: return normally
return with error (when error thrown)
The completion handler of dataTask is executed after connect returned.
This is why I would like to implement a throw scenario to my request If you are having such use case in mind, completion handler pattern might be easier:
		func connect(url: String,
								 onError errorHandler: @escaping (Error?)->Void) { //<-
				let encoded: Data
				do {
						encoded = try JSONEncoder().encode(connexion)
				} catch {
						print("Fail to encode newMed: \(error)")
						return
				}
				let url = URL(string: "/api/\(url)")!
				var request = URLRequest(url: url)
				request.setValue("application/json", forHTTPHeaderField: "Content-Type")
				request.httpMethod = "POST"
				request.httpBody = encoded
				URLSession.shared.dataTask(with: url) { data, res, error in
						if let error = error {
								errorHandler(error)
								return
						}
						guard let response = res else {
								errorHandler(ConnexionError.invalidServerRes) //<-
								return
						}
						guard let httpResponse = response as? HTTPURLResponse,
									case 200...299 = httpResponse.statusCode
						else {
								self.handleServerError(res!)
								return
						}
						guard let data = data else {
								print("data is nil")
								return
						}
						let decoder = JSONDecoder()
						do {
								let json = try decoder.decode(Connexion.self, from: data)
								print(json)
								self.connexion.id = json.id
								self.connexion.token = json.token
								self.connexion.sessionID = json.sessionID
								self.signInSuccess = true
						} catch {
								let dataString = String(data: data, encoding: .utf8) ?? "Unknown encoding"
								print("Invalid response \(error) - \(dataString)")
						}
				}.resume()
		}
And use it as:
				Button(action: {
						self.showGroup = false
						if connexion.isNotEmpty {
								self.connect(url: "url", onError: { err in
										self.showError = true
								})
						} else {
								self.showEmpty = true
						}
				}) {
						Text("button")
				}
Settings : Sorry, far from I expected. Please show all the customizable things of Postman, including Http Method, Authorization, Header and Body.