-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Description
Section/Content To Improve
https://github.com/codenomnom/axios-interceptors-docs/blob/v1.x/README.md#interceptors
Summary
The current documentation does not clearly explain that request interceptors execute in reverse order (LIFO) while response interceptors execute in the order they were added (FIFO). I find this utterly critical to inform, as it took me quite a while to debug a dynamically added interceptors in production 😅
I've researched this and came to the conclusion this is intended behavior.
The implementation in lib/core/Axios.js (lines ~130-140) explicitly uses different array methods for the two types of interceptors:
- Request interceptors: Use
unshift()→ LIFO (Last In, First Out / reverse order) - Response interceptors: Use
push()→ FIFO (First In, First Out / normal order)
The test suite even includes a comment acknowledging this behavior (source: test/specs/interceptors.spec.js):
/* request interceptors have a reversed execution order */Suggested Improvement
I'm preparing a PR to:
- Add a clear "Execution Order" subsection to the Interceptors documentation
- Include code examples showing the exact execution flow
Relevant File(s)
README.mdReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels