Version: 5.4.x

Read Server Uptime

To read the OpenHIM uptime you will need to make a TLS request to the OpenHIM API for the below method and endpoint.

Method: GET
Endpoint: {openhim_url}:8080/heartbeat

Example#

Copy the below code into a file titled openhim-api.js

(async () => {
const openhimOptions = {
apiURL: 'https://localhost:8080',
apiEndpoint: '/heartbeat',
rejectUnauthorized: false
}
const options = { method: 'GET',
url: `${openhimOptions.apiURL}${openhimOptions.apiEndpoint}`,
rejectUnauthorized: openhimOptions.rejectUnauthorized
}
request(options, (error, response, body) => {
if (error) throw new Error(error)
console.log({
statusCode: response.statusCode,
body
})
})
})()

Execute the below command in your terminal to run the nodejs script

node openhim-api.js

The response status code will be 200 if successful.