openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Timeout/Cancel requests w. node-fetch

Open Excodibur opened this issue 3 years ago • 2 comments

Is there a working way on how to timeout requests with generated APIs using node-fetch?

There is an example here https://github.com/ferdikoomen/openapi-typescript-codegen/blob/56c62af2d6901a128e403331324649bbf4d67cff/docs/canceling-requests.md that uses CancelablePromise, but both functions isRejected and isResolved don't seem to be implemented for that class, only isCancelled.

Excodibur avatar Jun 27 '22 10:06 Excodibur

This is resolved already? Otherwise I can create a pull-request

viniciuspalma avatar Jul 19 '22 14:07 viniciuspalma

This is resolved already? Otherwise I can create a pull-request

Doesn't seem like so as I faced the same issue. Only isCancelled is exposed at the moment.

Exposing isRejected and isResolved in the public API would solve it: https://github.com/ferdikoomen/openapi-typescript-codegen/blob/0dfebbdfc8bc92047e1abf84c205f6e3a3f50fa8/src/templates/core/CancelablePromise.hbs

If you don't do it @viniciuspalma let me know and I can take care of it.

Any feedback on this @ferdikoomen?

IvoPereira avatar Jul 28 '22 09:07 IvoPereira