0

I have a piece of Nats code which i can run in terminal following by node command but the same can i run in ionic2?

I need to run that nats code in IONIC2 after the click of button

Nats code:

submitBtn() { 
  var natnc = nc.connect({'url':'localhost:4222/';}) 
  var subject = "test.sub"; 
  var msg = "Hello World!"; 
  for(var i = 0;i < 100; i++) { 
    natnc.publish(subject, msg); 
    console.log('Published [' + subject + '] : "' + msg + '"'); 
  } 
}
Ivar Reukers
  • 7,560
  • 9
  • 56
  • 99
Bharat
  • 63
  • 1
  • 1
  • 4
  • Please add your code so we can help you. Thanks! – Ignacio Ara May 31 '18 at 07:03
  • submitBtn() { var natnc = nc.connect({'url':'http://localhost:4222/'}) var subject = "test.sub"; var msg = "Hello World!"; for(var i = 0;i < 100; i++) { natnc.publish(subject, msg); console.log('Published [' + subject + '] : "' + msg + '"'); } } – Bharat May 31 '18 at 07:07
  • This is what i have tried to run under the action submitBtn() – Bharat May 31 '18 at 07:08

0 Answers0