I have used KafkaJS library and configured an consumer code to fetch messages from a topic of one of my streaming API.
I have created a consumer.js file and I'm able to run the file from the location in the commandline using node consumer.js
But my requirement is to execute the consumer.js file from my javascript/cypress code. I have put the complete consumer.js code inside a method under a Class and tried to call but it fails.
Is there a way to run the node consumer.js command directly from the code OR else how can I call it from my class.
Tried the consumer code similar to this https://thecodebarbarian.com/getting-started-with-apache-kafka-in-node-js.html
Any help would be highly appreciated.
Thanks