API
The API service we will be using will use two HTTP methods (GET
and POST
) and four endpoints (/products
, /login
, /register
, and /pay
). We will mock up this service for testing and development reasons but will leave the implementation open to plug in external endpoints easily at a later stage:
/*** src/api.js ***/ export const get = uri => new Promise(resolve => { let response; switch (uri) { case '/products': response = [ { id: 1, name: 'Mastering Docker - Second Edition', author: 'James Cameron', img: 'https://d1ldz4te4covpm.cloudfront.net/sites/default /files/imagecache/ppv4_main_book_cover /B06565_MockupCover_0.png', price: 39.58, }, ... ]; break; default: return null; } setTimeout(() => resolve(response), 1000); return null; }); export const post = (uri, data) => new...