Last active
June 10, 2017 12:18
-
-
Save iamgoangle/2710fea5968e154d6959ad8248047f40 to your computer and use it in GitHub Desktop.
products.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // products.js | |
| var faker = require('faker'); | |
| function generateProducts () { | |
| let products = []; | |
| for (var id = 0; id < 50; id++) { | |
| var productName = faker.commerce.productName(); | |
| var price = faker.commerce.price(); | |
| var qty = faker.finance.amount(); | |
| products.push({ | |
| "id": id, | |
| "productName": productName, | |
| "price": price, | |
| "qty": qty | |
| }); | |
| } | |
| return { "products": products }; | |
| } | |
| // json-server requires that you export | |
| // a function which generates the data set | |
| module.exports = generateProducts(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "products": [ | |
| { | |
| "id": 0, | |
| "productName": "Handcrafted Metal Shoes", | |
| "price": "425.00", | |
| "qty": "508.54" | |
| }, | |
| { | |
| "id": 1, | |
| "productName": "Ergonomic Fresh Hat", | |
| "price": "548.00", | |
| "qty": "571.30" | |
| }, | |
| { | |
| "id": 2, | |
| "productName": "Sleek Wooden Pizza", | |
| "price": "705.00", | |
| "qty": "581.94" | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment