Edit in JSFiddle

var socket = new FIMKSocket("wss://cloud.mofowallet.org:7986/ws/");
socket.ready(function () {
  socket.callAPIFunction({requestType: "getState"}, function (data) {
    write("GetState says");
    write(JSON.stringify(data, null, "  "));
  });
});
<script type="text/javascript">
function write (text) {
    var p = document.createElement('pre');
    p.textContent = text;
    document.getElementById("output").appendChild(p);
}
</script>
<div id="output"></div>