Jump to content

RippleAPI: Attempting to retrieve server information


Recommended Posts

I would like to display the information about my new rippled validator.  I used to have a RippleAPI script that displayed the info from the XAGATE validator back in the day, unfortunately, that script has been lost to time and I need to write it again. 

I am attempting to retrieve server info using this code (and the public rippled server to test):

<html>
    <head><title>SOS Rippled Validator</title></head>
    <body>
        <h1>The Streets of Silver Rippled Validator</h1>
        <p>Under construction</p>
        <p><script src="ripple-latest.js"></script><script>
        //const RippleAPI = require('ripple-latest.js').RippleAPI;
        console.log(ripple);
        const api = new RippleAPI({
          server: 'wss://s1.ripple.com' // Public rippled server hosted by Ripple, Inc.
        });
        api.on('error', (errorCode, errorMessage) => {
          console.log(errorCode + ': ' + errorMessage);
        });
        api.on('connected', () => {
          console.log('connected');
        });
        api.on('disconnected', (code) => {
          // code - [close code](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent) sent by the server
          // will be 1000 if this was normal closure
          console.log('disconnected, code:', code);
        });
        api.connect().then(() => {
          console.log("Connected.");
          return api.getServerInfo().then(info => {/* ... */
              console.log(info);
          });
        }).then(() => {
          return api.disconnect();
        }).catch(console.error);
        </script></p>
    </body>
</html>

Please see the attached image for the errors and warnings thrown in the console.  Any help would be greatly appreciated.

rippleapigetserverinfo.png

Link to post
Share on other sites
1 hour ago, jn_r said:

Taylor, see here a working sample: https://xrpl.org/get-started-with-rippleapi-for-javascript.html#4-build-with-yarn

Ah thank you so much for the link!

Still having problems getting the script to work with my rippled server though.  I'm getting a code 200 for some reason when connecting over wss.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.