Hello, world!
The most basic example that we will use to start with is to show you how to insert the text "Hello, world!" in an input field.
After creating a new Custom Generator and giving it a name, copy and paste the following code:
return 'Hello, world!';
Yep! That's it! One line of code, and Fake Data will insert that in any form input that uses this generator. Below is a video example on how to do that:
Let's see another example. This time we will tell Fake Data to insert the current date and time in the form input, if for whatever reason you need that:
let date = new Date();
return date.toGMTString();
The result for the above code should be something like this:
Mon, 06 Jun 2022 14:55:16 GMT
From the two examples above we can conclude a few things:
- You can use any javascript code that you want.
- The value that you want to be inserted should be
return
ed from your code. - Fake Data is awesome!