Beagle v1.5 não é mais mantida ativamente. A versão documentada que você está visualizando pode conter funcionalidades depreciadas. Para obter as funcionalidades mais recentes, consulte a nossa última versão .
A classe sendRequest
é responsável por tratar requisições HTTP
A estrutura do Send Request é:
Atributo | Tipo | Obrigatório | Definição |
---|---|---|---|
url | String ou Binding | ✓ | URL do servidor. |
method | RequestActionMethod ou Binding | ✓ | Método HTTP. |
headers | Map <String, String> ou Binding | Itens do header para a requisição. | |
data | Any | Conteúdo a ser enviado junto a requisição. | |
onSuccess | List<Action> | Ação tratativa de sucesso. | |
onError | List<Action> | Ação tratativa de erro. | |
onFinish | List<Action> | Ação tratativa de finalização. |
Segue abaixo um exemplo de botão que faz uma requisição do tipo POST
enviando dados de um usuário:
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 = "Success"
)
),
onError = listOf(
Alert(
title = "ERROR",
message = "Error"
)
),
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.