How to use a Webhook in Angular?

Asked

Viewed 652 times

0

I have never used any communication with Webhook, at the moment I am receiving communication from API Moip Signatures, when a new subscriber is registered I receive a JSON with the event and subscriber information that was created.

I’m using the Requestbin to do the tests, since I cannot receive Webhook on my local server (localhost:4200).

I would like to know how to listen to a Webhook communication and see which event was sent by the Moip Signatures API when some action is executed in the API.

For example when an invoice is created, the event is triggered INVOICE.CREATED. https://dev.moip.com.br/v1.5/reference#example-de-webhook-de-faturas-Invoices

I would like to control with a service when I receive a Webhook and notify the user of the action he has taken, whether a payment made etc.

1 answer

1


A Webhook functions as a callback - in this case a URL that is called by the remote server.

I would like to know how to listen to a Webhook communication and see which event was sent by the Moip Signatures API when some action is executed in the API.

You need to expose your development machine to the internet so that external requests reach your machine.

The way to implement this will depend on your local network topology - via NAT or adding your machine to the domain DMZ, for example.

  • I am using ngrok for testing and receiving a JSON via POST from the API, but I need to get this JSON every time I receive a POST from the API, as I do for listening if I receive a POST in Angular 5?

  • @Luizcardoso being the back-end the target of callback call I would say you may need to inform the frontend. Two possibilities: Polling or stream (websocket or similar).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.