Advertisement
irobust

Fake API products with comments

Aug 25th, 2018 (edited)
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = () => {
  2.   var faker = require('faker');
  3.   const data = { products: [] }
  4.   for (let i = 0; i < 10; i++) {
  5.     data.products.push({
  6.         productCode: faker.commerce.product(),
  7.         productName: faker.commerce.productName(),
  8.         price: faker.commerce.price(),
  9.         rating: faker.random.number({min: 1, max: 5}),
  10.         comments: [
  11.             { message: 'Test Comment 1' },
  12.             { message: 'Test Comment 2' },
  13.             { message: 'Test Comment 3' }
  14.         ]
  15.     })
  16.   }
  17.   return data
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement