linkedin connections | scrape linkedin contacts | connect on linkedin | Search

The code imports a module and a function from it, then uses asynchronous execution to call the function, which returns a promise. The promise is handled with .then for success and .catch for errors, sending the result or error to the $.sendResult or $.sendError functions, respectively.

Cell 3

var importer = require('../Core');
var syncLinkedInContacts = importer.import("sync linkedin contacts");
$.async();
syncLinkedInContacts()
    .then(r => $.sendResult(r))
    .catch(e => $.sendError(e));

What the code could have been:

import { importSyncLinkedInContacts } from '../Core';
import { sendResult, sendError } from './utility';
import { async as $ } from './async';

/**
 * Synchronize LinkedIn contacts
 * @returns {Promise}
 */
async function syncLinkedInContacts() {
    try {
        const result = await importSyncLinkedInContacts();
        await sendResult(result);
    } catch (error) {
        await sendError(error);
    }
}

// Call the function
syncLinkedInContacts();

Code Breakdown

Importing Modules

Asynchronous Execution

Function Execution and Error Handling