linkedin connections | connect add friends linkedin | Cell 7 | Search

This code snippet imports a module, specifically the addLinkedinConnections function, and executes it asynchronously using the $.async() and .then()/.catch() methods. The addLinkedinConnections function is called with null and an empty string as arguments, and the result is sent using the $.sendResult(r) method, while any errors are sent using $.sendError(e).

Cell 6

var importer = require('../Core');
var addLinkedinConnections = importer.import("connect add friends linkedin");

$.async();
addLinkedinConnections(null, '')
    .then(r => $.sendResult(r))
    .catch(e => $.sendError(e))

What the code could have been:

import Core from '../Core';
import addLinkedinConnections from '../Core/connect/add-friends/linkedin';

/**
 * Async function to add LinkedIn connections
 */
async function addLinkedInConnections() {
    try {
        const result = await addLinkedinConnections(null, '');
        $.sendResult(result);
    } catch (error) {
        $.sendError(error);
    }
}

// Call the function
addLinkedInConnections();

Code Breakdown

Importing Modules

var importer = require('../Core');

Function Call

var addLinkedinConnections = importer.import('connect add friends linkedin');

Async Execution

$.async();

Asynchronous Operation

addLinkedinConnections(null, '')
   .then(r => $.sendResult(r))
   .catch(e => $.sendError(e))