openapistack / openapi-client-axios

JavaScript client library for consuming OpenAPI-enabled APIs with axios
https://openapistack.co
MIT License
556 stars 67 forks source link

EventEmitter for openapi-client-axios #163

Closed dannyhaak closed 1 year ago

dannyhaak commented 1 year ago

We have a use case where we want to get events on when openapi-axios-client functions are called. The use case is that we have a platform with 'custom' JavaScript applications build by our users. Our users call openapi-axios-client functions to call our backend APIs. We want to add offline capabilities, however, we want to keep using openapi-axios-client as the 'main' frontend to our users (instead of a custom wrapper). One way of doing that would be to add events to openapi-axios-client to learn when functions are called, and when the results is obtained.

I am willing to make a PR to add this functionality - but before doing that - is this something you will merge into the main project?

anttiviljami commented 1 year ago

Hi @dannyhaak! Interesting use case.

Did you consider just using axios interceptors? Do you see any reason this would't work in your case?

dannyhaak commented 1 year ago

Ah, that's an interesting option! Wasn't aware of that. Let me try that, and report back.

dannyhaak commented 1 year ago

Yes, it seems to work perfectly fine for my use case. Case closed :).