Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating advanced javascript responses #693

Open
skaskiewicz opened this issue Feb 28, 2025 · 0 comments
Open

creating advanced javascript responses #693

skaskiewicz opened this issue Feb 28, 2025 · 0 comments

Comments

@skaskiewicz
Copy link

Hi, I have a question: how should I import/export JavaScript functions/classes that are stored in helper files? My mock is created based on dynamically generated data, so I use JavaScript. To run the mock, I use the official Docker image.
helper.js
export function daysLeft(currentDate, secondDate){ var date1 = new Date(currentDate); var date2 = new Date(secondDate); var difference = date2.getTime() - date1.getTime(); return Math.ceil(difference / (1000 * 3600 * 24)); }
response1.js
import { daysLeft} from './helper.js';
error when running
aused by: org.graalvm.polyglot.PolyglotException: ReferenceError: require is not defined at <js>.__run(Unnamed:17) ~[?:?] at org.graalvm.polyglot.Value.invokeMember(Value.java:971) ~[imposter.jar:?]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant