Skip to content

Commit 0ebb9dd

Browse files
committed
Minor fix
1 parent 6e025c0 commit 0ebb9dd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Examples/LocalDebugging/MyApp/MyApp/ContentView.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct ContentView: View {
2929
Button {
3030
Task {
3131
isLoading = true
32-
response = await register()
32+
response = await self.register()
3333
isLoading = false
3434
}
3535
} label: {
@@ -45,14 +45,14 @@ struct ContentView: View {
4545
}
4646
}
4747
}
48-
.disabled(buttonDisabled)
48+
.disabled(buttonDisabled || isLoading)
4949
.opacity(buttonDisabled ? 0.5 : 1)
5050
Text(response)
5151
}.padding(100)
5252
}
5353

5454
func register() async -> String {
55-
guard let url = URL(string: "http://localhost:9001/invoke") else {
55+
guard let url = URL(string: "http://127.0.0.1:7000/invoke") else {
5656
fatalError("invalid url")
5757
}
5858
var request = URLRequest(url: url)
@@ -64,17 +64,17 @@ struct ContentView: View {
6464
request.httpBody = jsonRequest
6565

6666
do {
67-
let (data, urlResponse) = try await URLSession.shared.data(for: request)
67+
let (data, response) = try await URLSession.shared.data(for: request)
6868

69-
guard let httpResponse = urlResponse as? HTTPURLResponse else {
69+
guard let httpResponse = response as? HTTPURLResponse else {
7070
return "invalid response, expected HTTPURLResponse"
7171
}
7272
guard httpResponse.statusCode == 200 else {
7373
return "invalid response code: \(httpResponse.statusCode)"
7474
}
7575

76-
let response = try JSONDecoder().decode(Response.self, from: data)
77-
return response.message
76+
let jsonResponse = try JSONDecoder().decode(Response.self, from: data)
77+
return jsonResponse.message
7878
} catch {
7979
return error.localizedDescription
8080
}

0 commit comments

Comments
 (0)