How to use the jayson/promise.Client.https function in jayson

To help you get started, we’ve selected a few jayson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ShipChain / engine / src / vaults / RemoteVault.ts View on Github external
private async sendOutgoingRequestToRemote(): Promise {
        const parsedUrl = new URL(this.linkEntry.remoteUrl);
        let client: Client;

        if (parsedUrl.protocol === 'https:') {
            client = Client.https({
                host: parsedUrl.hostname,
                port: +parsedUrl.port,
            });
        } else if (parsedUrl.protocol === 'http:') {
            client = Client.http({
                host: parsedUrl.hostname,
                port: +parsedUrl.port,
            });
        } else {
            throw new Error(`Invalid protocol in linkEntry [${parsedUrl.protocol}]`);
        }

        // Call RPC for remote Engine
        logger.debug(`Calling remote Engine ${this.linkEntry.remoteUrl}`);
        const resp = await client.request('vaults.linked.get_linked_data', { linkEntry: this.linkEntry });