[{"data":1,"prerenderedAt":235},["ShallowReactive",2],{"news-item-\u002Fnews\u002Fmockdata-fakerjs":3},{"id":4,"title":5,"body":6,"category":222,"created by":223,"date":224,"description":225,"extension":226,"meta":227,"navigation":228,"path":229,"sections":230,"seo":231,"stem":232,"thumbnail":233,"__hash__":234},"content_en\u002Fnews\u002Fmockdata-fakerjs.md","Mock data with FakerJs",{"type":7,"value":8,"toc":217},"minimark",[9,17,21,30,40,53,59,62,73,76,82,85,91,94,100,103,109,112,115,121,123,129,136,142,145,151,157,162,165,171,173,179,183,186,192,198,201,204,210],[10,11,13],"h1",{"id":12},"what-is-fakerjs",[14,15,16],"strong",{},"What is FakerJs ?",[18,19,20],"p",{},"FakerJs is a JavaScript library that helps generate random data according to different types of data such as email, phone number, address, password, image and so on…",[18,22,23,24],{},"Demo: ",[25,26,27],"a",{"href":27,"rel":28},"https:\u002F\u002Frawgit.com\u002FMarak\u002Ffaker.js\u002Fmaster\u002Fexamples\u002Fbrowser\u002Findex.html",[29],"nofollow",[10,31,33,36,37],{"id":32},"when-is-it-useful",[14,34,35],{},"When is it"," ",[14,38,39],{},"useful?",[41,42,43,47,50],"ul",{},[44,45,46],"li",{},"When working with the Front End, we need the data to be processed on the user interface when the real data from the API is incomplete.",[44,48,49],{},"Creates dummy data sent from API when components connecting to database have problems (database, service, host ...)",[44,51,52],{},"Generate json sample data for API testing.",[10,54,56],{"id":55},"nodejs-usage",[14,57,58],{},"NodeJS usage",[18,60,61],{},"Via npm:",[63,64,69],"pre",{"className":65,"code":67,"language":68},[66],"language-text","npm i faker\n","text",[70,71,67],"code",{"__ignoreMap":72},"",[18,74,75],{},"Import (TypeScript project):",[63,77,80],{"className":78,"code":79,"language":68},[66],"import faker = require(\"faker\");\n",[70,81,79],{"__ignoreMap":72},[18,83,84],{},"OR JavaScript project:",[63,86,89],{"className":87,"code":88,"language":68},[66],"var faker = require(\"faker\");\n",[70,90,88],{"__ignoreMap":72},[18,92,93],{},"For example, create 3 random Employee objects by FakerJs:",[63,95,98],{"className":96,"code":97,"language":68},[66],"const generateEmployee = () => {\n\n  return {\n\n    id: faker.random.uuid(),\n\n    first_name: faker.name.firstName(),\n\n    last_name: faker.name.lastName(),\n\n    email: faker.internet.email(),\n\n  };\n\n};\n\n\u002F\u002FReturn 3 object users\n\n=>> Array.from({ length: 3 }, generateEmployee)\n",[70,99,97],{"__ignoreMap":72},[18,101,102],{},"The result:",[63,104,107],{"className":105,"code":106,"language":68},[66],"[\n  {\n    \"id\": \"653551ca-29dc-458d-90dd-1c7a04004350\",\n    \"first_name\": \"Yadira\",\n    \"last_name\": \"Zieme\",\n    \"email\": \"Russel_Will88@yahoo.com\"\n  },\n  {\n    \"id\": \"14243402-a6f9-4005-bc61-bb1d25f23183\",\n    \"first_name\": \"Nyah\",\n    \"last_name\": \"Hermiston\",\n    \"email\": \"Sigrid77@gmail.com\"\n  },\n  {\n    \"id\": \"60dbec10-2898-4571-8187-31072f849ed9\",\n    \"first_name\": \"Reed\",\n    \"last_name\": \"Towne\",\n    \"email\": \"Alejandrin.Simonis@hotmail.com\"\n  }\n]\n",[70,108,106],{"__ignoreMap":72},[18,110,111],{},"Faker Js now supports multi language generation. Example:",[18,113,114],{},"Define the locale before creating the employee object:",[63,116,119],{"className":117,"code":118,"language":68},[66],"faker.locale = 'ja';\n",[70,120,118],{"__ignoreMap":72},[18,122,102],{},[63,124,127],{"className":125,"code":126,"language":68},[66],"[\n  {\n    \"id\": \"c0a9b596-ade2-4d9e-bddc-3a6e6ed43fcb\",\n    \"first_name\": \"結菜\",\n    \"last_name\": \"加藤\",\n    \"email\": \"海翔_井上@gmail.com\"\n  },\n  {\n    \"id\": \"12381746-bb9e-479c-adf0-ba7887392a06\",\n    \"first_name\": \"杏\",\n    \"last_name\": \"渡辺\",\n    \"email\": \"結菜_清水11@gmail.com\"\n  },\n  {\n    \"id\": \"264a8702-3318-43d1-9518-748046ff6ac5\",\n    \"first_name\": \"心愛\",\n    \"last_name\": \"清水\",\n    \"email\": \"結衣_山田57@gmail.com\"\n  }\n]\n",[70,128,126],{"__ignoreMap":72},[18,130,131,132],{},"Available data types and languages refer to: ",[25,133,134],{"href":134,"rel":135},"http:\u002F\u002Fmarak.github.io\u002Ffaker.js\u002F",[29],[10,137,139],{"id":138},"seed-in-fakerjs",[14,140,141],{},"Seed in FakerJs",[18,143,144],{},"FakerJs helps us to generate random data. But in some cases, we need the data generated to be the same in different processes. Seed helps us to solve this:",[63,146,149],{"className":147,"code":148,"language":68},[66],"    faker.seed(1);\n\n    var number1st = faker.random.number(); \u002F\u002F name1st = 123\n\n    \u002F\u002F Setting the seed again resets the sequence.\n\n    faker.seed(1);\n\n    var number2nd = faker.random.number(); \u002F\u002F number2nd = 123\n\n    \u002F\u002F => number1st === number2nd\n",[70,150,148],{"__ignoreMap":72},[10,152,154],{"id":153},"other-services-of-fakerjs",[14,155,156],{},"Other services of FakerJs",[158,159,161],"h2",{"id":160},"fakerjs-api","FakerJs API",[18,163,164],{},"The API will return a single data type field according to the parameter when requested",[63,166,169],{"className":167,"code":168,"language":68},[66],"http:\u002F\u002Ffaker.hook.io\u002F?property=internet.email&locale=en\n",[70,170,168],{"__ignoreMap":72},[18,172,102],{},[63,174,177],{"className":175,"code":176,"language":68},[66]," \"Ted37@hotmail.com\"\n",[70,178,176],{"__ignoreMap":72},[158,180,182],{"id":181},"faker-cloud","Faker Cloud",[18,184,185],{},"Quickly create one or more dummy data, very useful for when we need a lot of data to test the API, the command to insert into the database series, etc... Support many formats CSV, JSON, MySQL, MSSQL etc...",[18,187,188],{},[25,189,190],{"href":190,"rel":191},"https:\u002F\u002Ffakercloud.com\u002F",[29],[10,193,195],{"id":194},"summary",[14,196,197],{},"Summary:",[18,199,200],{},"FakerJs is a handy and compact library. It is suitable for both back-end, front-end and especially FakerCloud which is quite suitable for testers. It simplifies many things that are almost time-consuming to do such as inserting a series of records into the database, create JSON lists to send to the API, support multilingual data, etc.",[18,202,203],{},"References:",[18,205,206,207],{},"1. ",[25,208,134],{"href":134,"rel":209,"title":134},[29],[18,211,212,213],{},"2. ",[25,214,215],{"href":215,"rel":216,"title":215},"https:\u002F\u002Fzetcode.com\u002Fjavascript\u002Ffakerjs\u002F",[29],{"title":72,"searchDepth":218,"depth":218,"links":219},2,[220,221],{"id":160,"depth":218,"text":161},{"id":181,"depth":218,"text":182},"tech talk","KHUYEN DO TIEP","2021-05-05","What is FakerJs ? FakerJs is a JavaScript library that helps generate random data according to different types of data such as email, phone number, address, password, image and so on…","md",{},true,"\u002Fnews\u002Fmockdata-fakerjs",null,{"title":5,"description":225},"news\u002Fmockdata-fakerjs","https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2026\u002F06\u002F05103100\u002FFaker.png","KTGHsffJHjcT1hN8KonxSOEOWVs-bgYheo4guQ0Kzw8",1782263086011]