SendRequest
is used to make HTTP requests.
The Send Request structure is:
Attribute | Type | Required | Definition |
---|---|---|---|
url | String or Binding | ✓ | Server URL. |
method | RequestActionMethod or Binding | ✓ | HTTP method. |
headers | Map <String, String> or Binding | Header items for the request. | |
data | Any | Content that will be deliver with the request. | |
onSuccess | List<Action> | Triggers a Success action or list of actions. | |
onError | List<Action> | Triggers an Error action or list of actions. | |
onFinish | List<Action> | Triggers a Finish action or list of actions. |
The example below shows a button that triggers a POST
request with some user data:
Button(
text = "Send a request",
styleId = "DesignSystem.MyNativeButtonStyle",
onPress = listOf(
SendRequest(
url = https://myUrl.com/endpoint",
method = RequestActionMethod.POST,
data = User(
name = "John",
email = "jonh@email.com",
password = "password",
confirmPassword = "password"
),
headers = mapOf(
"Content-Type" to "application/json"
),
onSuccess = listOf(
Alert(
title = "SUCCESS",
message = "@{onSuccess.data}"
)
),
onError = listOf(
Alert(
title = "ERROR",
message = "@{onError.data}"
)
),
onFinish = listOf(
Alert(
title = "FINISH",
message = "Finish"
)
)
)
)
)
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.