Setting up a mock API

We need some mock data and a means of persisting any updates. If you store the data locally in a JSON file, any changes you make to the transactions will be lost as soon as you refresh the page. We could set up a local server with a library like Express, mock a database, write routes, and so on. But instead we're going to take advantage of the excellent development tooling available online. The online too jsonstore.io is allows you to store JSON data for small projects and provides endpoints out of the box. Take the following steps to get your mock API up and running:

  1. Navigate to https://www.jsonstore.io/ and press the Copy button to copy the endpoint to your clipboard; this is the endpoint you'll be making HTTP requests to.
  2. Go to the JSFiddle at https://jsfiddle.net/mikerourke/cta0km6d, paste your jsonstore.io endpoint into the input, and press the Populate Data button.
  3. Open up a new tab and paste your jsonstore.io endpoint in the address bar and add /transactions to the end of the URL and press Enter. If you see the contents of the JSON file in your browser, the API setup was successful.

Keep that jsonstore.io endpoint handy—you'll need it when we build the JavaScript portion of the app.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset