Add a button to the page and paste the following into its On Click event:
// Use the Gateway REST Service to simulate a coin flip
var response = gateway.rest.get("myGateway", "flip");
// Display the results on the form
if(response.isSuccess()) {
fields.result.value = response.getBody();
}
else {
fields.result.value = "Unknown";
}