Hello i am new to this and i need to make a script about date validation:
i was wondering how to make a script for a mockapi.io that contains some dummy dates, when i select the automatically generated ones it just gives me random numbers, how can you edit the faker.js template to show real dates especially current and future dates?
thank you very much
Why is creating a few dates by hand or using
new Date not an option? Do you need that data coming from a server?
i was hoping to use mock.api to test the chatbot on it, it does not have an option to get it from an excel or something else.
If that’s doing what I think it’s doing, then you can’t specify using faker, you’d need to actually manually write the date for each one (defeating the point). You’re out of luck on this I think. You’d need to use/write something more sophisticated to get what you want.
All faker generation is via functions, so
$name.firstName is running the function
name.firstName(). That’s fine if you want it to just randomly generate anything using faker functions that take no arguments. But it prevents you from using any of the faker functions that accept arguments (
date.between for example).
If you look at the demo page for faker, that has this issue: it returns null for
date.between because it’s just running
date.between() with no arguments.
There also won’t be a way to have a date created based on another object (so for example, you have a fake set of articles and each has a date subsequent to the previous one) because the tool you’re using isn’t set up to support that, it’s just trying to be as simple as possible.
so i can not use in faker.js something like $date.future for future dates?
If that is the case how can i create a manual database and then call it with the api call? any notepad made list works or?
This is what the mock api makes, and the dates are not “dates” that is my issue
Yeah, afaics you can use date.future, that’s just a call with no args. It’s just that you can’t control anything about the date. It’s always going to be random and you can’t make use of any of the faker functions that let you use arguments to narrow the scope of the data generated
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.