I'm actually working on microservices project using a nats-streaming-server as a event-bus and i trying to write a publisher.ts file but i face this erreur
PS: i'm writing this code with typescript
Property 'on' does not exist on type 'Stan'.ts(2339)
import nats, { connect, Message } from 'node-nats-streaming';
console.clear();
const stan = nats.connect('ticketing', '123', {
url: 'http://localhost:4222'
});
stan.on('connect', () => {
console.log('Listener connected to NATS');
const subscription = stan.subscribe('ticket:created');
subscription.on('message', (msg: Message) => {
const data = msg.getData();
if (typeof data === 'string') {
console.log(`Recieved event #${msg.getSequence()}, with data: ${data}`);
}
});
})