reactjs – connect amqplib (RabbitMQ) react and typescript
install packages i.imgur.com/XfPg1p3.png
try connect amqp with backend and get an error
install “@types/amqplib”: “^0.8.2″,”amqplib”: “^0.8.0”,
import amqp from 'amqplib/callback_api'
const Notifications = ({ isMobile }:any):JSX.Element => {
useEffect(() => {
amqp.connect('amqps://ask-a-vet:12345678987654321@b-b8932d4d-4ad7-45f4-a581-9e1e3e83c93c.mq.ap-southeast-2.amazonaws.com:5671/dev', function(error0, connection) {
if (error0) {
throw error0;
}
connection.createChannel(function(error1, channel) {
console.log(error1, channel);
});
});
},[]);
return (
<>
<NotificationWrap isMobile={isMobile}>
<NotificationBellIcon onClick={setNotificationToggle} />
</NotificationWrap>
</>
)
}
export default Notifications
after I get an error
i.imgur.com/C8cNIdD.png
Read more here: Source link