CHAPTER 8

Step 8: Get Next Event with the ADP Core Library

The getNextEvent() method is used to retrieve events that are waiting on the event notifications queue. The getNextEvent() method will return the next available event as a JSON event object. If an event is not available it will return an empty object.

After the event has been successfully retrieved, it will be automatically deleted so that subsequent calls to getNextEvent() will return new events (or an empty object).

The structure of the resulting JSON event object is the same as that returned by a normal REST API call.

The code example below shows how to retrieve event notifications after the Consumer Application Instance has been created.

app.getNextEvent( (err, body, headers ) => {
    console.log( 'Received: ', err, body, headers );
});