September 2018
Intermediate to advanced
328 pages
9h 10m
English
The API provides means for adding, editing, removing, and querying transactions in the form of HTTP methods defined on a fetch call. To simplify the process of performing these actions, we'll write some API wrapper functions. Create a file in the /src/store folder named api.js and populate it with the following contents:
// Paste your jsonstore.io endpoint here (no ending slash):const API_URL = '[JSONSTORE.IO ENDPOINT]';/** * Wrapper for performing API calls. We don't want to call response.json() * each time we make a fetch call. * @param {string} endpoint Endpoint (e.g. "/transactions" to make API call to * @param {Object} init Fetch options object containing any custom settings * @returns {Promise<*>} * @see ...Read now
Unlock full access