SendRequest

You will find here SendRequest definition and its attributes details

What is it?

SendRequest is used to make HTTP requests.

The Send Request structure is:

AttributeTypeRequiredDefinition
urlString or BindingServer URL.
methodRequestActionMethod or BindingHTTP method.
headersMap <String, String> or BindingHeader items for the request.
dataAnyContent that will be deliver with the request.
onSuccessList<Action>Triggers a Success action or list of actions.
onErrorList<Action>Triggers an Error action or list of actions.
onFinishList<Action>Triggers a Finish action or list of actions.

How to use it?

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"
                    )
                )
            )
        )
    )