October 2018
Beginner to intermediate
478 pages
10h 8m
English
After creating the initial layout, let's implement the API access layer by encapsulating it in its own dedicated file and namespace:
'use-strict';(function (window) { const ns = window.api = window.api || {}; // EDIT the URL with the the address of your REST API - const baseUrl = 'http://localhost:55564/api'; // build the URL for a REST API call and include the parameters function getApiAction(action, parameters = null) { const p = (!parameters || parameters.length === 0) ? '' : `/${Object.values(parameters).join('/')}`; return `${baseUrl}/${action}${p}`; } // iterate through products returned from REST API and set the primary image accordingly for each product ...Read now
Unlock full access