

Step 3: Testing the Code from the Command Line in VS Codeįigure 3 illustrates how to run the code from within VS Code. Listing 1: JavaScript Module const fetch = require('node-fetch') Ĭonst json = fetch(url).then(response => response.json()) If you've worked with JavaScript promises in the past, you'll appreciate the code efficiencies with the fetch API. For more information on the module, consult this resource.

Lines 3-12 represent the exported JavaScript module. Line 1 loads the node-fetch module and line 14 loads the make-runnable module. Listing 1 illustrates a simple JavaScript module. Step 2: Let's Write Some JavaScript Code! Figure 2 illustrates the make-runnable installation.įigure 2: The make-runnable npm package installation. With reduced friction comes increased productivity. The idea behind this module is to reduce the friction with testing JavaScript modules. make-runnable: makes it easy to run exported module functions from the command line.Figure 1 illustrates the node-fetch installation.įigure 1: The node-fetch npm package installation. For more information on JavaScript promises, consult. The fetch API, unlike XHR, is a compact way of making asynchronous calls and interacting with promises.

