Skip to content

Latest commit

 

History

History
67 lines (54 loc) · 1.21 KB

File metadata and controls

67 lines (54 loc) · 1.21 KB

Check Api Availability

Here, viewServiceAvailability() creates a GET request to /heartbeat

This endpoint returns the current status of the API

Usage/Examples

/**
 * Set up your function to be invoked
 */
const viewServiceAvailability = async (debug = false) => {
  try {
    /**
     * Construct a request object and set desired parameters
     */
    const request = new mmapi.agentService.viewServiceAvailability();

    if (debug) {
      console.log("Request: ", JSON.stringify(request, null, 4));
    }

    /**
     * Call API with your client and get a response for your call
     */
    const response = await client.execute(request);

    if (debug) {
      console.log("Response Status: ", response.status);
      console.log("Response Data: ", JSON.stringify(response.data, null, 4));
    }

    /**
     * Return a successful response
     */
    return response;
  } catch (err) {
    /**
     * Handle any errors from the call
     */
    if (debug) {
      console.log(err);
    }

    /**
     * Return an error response
     */
    return err;
  }
};

/**
 * Invoke the function
 */
viewServiceAvailability(true);

Example Output

200

{
  "serviceStatus": "available"
}