Chapter 6. Modify the Client App
Change the Client App to also show the timestamp property from the received server response.
First, create a placeholder for the response.
- Navigate to the Apps, Cloud Apps & Services page.
- Open the Cordova App Client App.
- Open the Editor.
-
Open the
www/index.htmlfile. Add a new
<div>that will show the receivedtimestamp.This element acts as a placeholder for the received value.
Find this line:
<div id="cloudResponse" class="cloudResponse"></div>
Replace it with the following:
<div id="cloudResponse" class="cloudResponse"></div> <div id="timestamp" class="cloudResponse"></div>
- Save the changes using File > Save, or using the Ctrl + S keyboard shortcut (Windows) or cmd + S keyboard shortcut (Mac).
Modify the handler of the Say Hello From The Cloud button to use the received timestamp value to populate the placholder.
Open the
www/js/hello.jsfile in the editor.This file contains a click handler for the Say Hello From The Cloud button, which uses the
$fh.cloudAPI to call the/helloendpoint of the Cloud App and populates the placeholder<div id="timestamp">element.Set the placeholder to the received
timestampvalue.Find the following code:
document.getElementById('cloudResponse').innerHTML = "<p>" + res.msg + "</p>";Replace it with the following:
document.getElementById('cloudResponse').innerHTML = "<p>" + res.msg + "</p>"; document.getElementById('timestamp').innerHTML = "<p>" + res.timestamp + "</p>";Save your changes.
The preview will update automatically.
Click Say Hello From The Cloud in the preview.
The area below the button now also contains a long string of numbers, which represent the time stamp. If it does not work, try refreshing the page.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.