Closed fireton closed 1 year ago
Hello,
Thank you for pointing it out. I updated the documentation to make it more clear that the return value is a Promise which will resolve to a string (as this is intended).
Your code is correct. Alternatively, you can also write it like this:
return new Promise(async resolve => {
let full_name = await fakeData.getLastGeneratedValue('full_name');
resolve(full_name.toLowerCase().replace(' ', '.') + '@fakemail.com');
});
Should I consider always returning Promise
in my custom generators code, not strings?
Pretty much all of the functions that handle generators will return a Promise
. But from your custom code, it doesn't matter if you return a string
or a Promise
. Fake Data will handle both fine.
getLastGeneratedValue
does not returnsstring
butPromise
.So I can't write in my custom generator code something like
return fakeData.getLastGeneratedValue('full_name').toLowerCase().replace(' ', '.') + '@fakemail.com';
instead I have to write