-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The client/resource modules are based on the EventEmitter, but they don't currently emit/relay events.
It would be nice to have the client/resource emit events about the request so the following scenarios would work:
API = new Resource({...})
API.on('request', event => {
console.log(`Method: ${event.method}`)
console.log(`URL: ${event.URL}`)
console.log(`Body: ${event.body}`)
})
API.on('post', event => {...})
API.on('get', event => {...})
API.on('put', event => {...})
API.on('delete', event => {...})The primary use case for this functionality is logging, but it could also be used for security hooks. Ideally, a before (i.e. before.post) and after (just post) version of each event would be useful, allowing developers to potentially abort or modify requests before they're actually sent.
This could also be useful for post-processing data, such as augmenting the response body of a request before inserting the data into an application.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request