How to fetch data/products from a server?

1. First of all, please make sure you return a valid JSON (an array of categories) from the server. Please follow this format.

2. Open the "js/products/products.js" file.

3. Go to the "init" function and remove the loop through the "list" array.

4. Set the path to your JSON and call the "fetch" function, like shown in the screenshot.

5. Inside the "success" function paste all the code that was initially inside the "init" function.

6. Add a "self" variable, like shown in the screenshot.

7. Replace all the "this" keywords within the "success" function with the "self" variable.


If the data is valid, now all the products should be fetched from the server.

Tags: database, JSON, server

Last update:
2016-03-28 12:09
Vlad Sargu
Average rating:0 (0 Votes)