Nodejs SDK in repl.it?

Sean_510793
Sean_510793 Posts: 69 admin
edited September 2020 in Questions

Can I set up the Nodejs SDK for use within repl.it?

Best Answer

  • Ben_132821
    Ben_132821 Posts: 4
    Answer ✓

    Yes! Using the Node.js SDK from repl.it is pretty straightforward. You first need to add the @catalytic/sdk NPM package via the "add package" button on the left sidebar. You'll also need to set up an access token, following these instructions in the docs. With that in place, you should be able to use all of the SDK's functionality. Here's an example:

    const { CatalyticClient } = require('@catalytic/sdk');
    const catalytic = new CatalyticClient('paste-your-access-token-here');
    (async function getWorkflows () {
        const matches = await catalytic.workflows.find({
            query: 'Employee'
        });
        console.log(`Found ${matches.workflows.length} workflows`);
    })();
    

    I recommend creating a new token rather than re-using an existing one so that you can delete the token when you are done. That's good practice any time you are exposing a token to a third party (repl.it in this case).