Skip to content

Conversation

@codenomnom
Copy link

Description

This PR clarifies the execution order of interceptors in the axios documentation.

Problem

Request interceptors execute in reverse order (LIFO) while response interceptors execute in normal order (FIFO). This intentional behavior is:

  • ✅ Implemented explicitly in the code (unshift vs push)
  • ✅ Acknowledged in test comments
  • Not documented anywhere

I was extremel surprised by this behavior and assumed it's a bug, when it's actually an intentional design that I guess creates a symmetric middleware/"onion" pattern? Anyways, I do believe it's a must to be properly documented.

Changes

I've updated the README.md - Interceptors section. There are no real code changes, so no testing is required. I've verified markdown rendered properly.

Fixes #7200

- Add 'Interceptor Execution Order' subsection
- Document reverse order for request interceptors
- Document normal order for response interceptors
- Add examples

Fixes axios#7200
@github-actions github-actions bot added the pr::docs PR that changes project documentation label Oct 31, 2025
@codenomnom
Copy link
Author

@jasonsaayman I've now figured the https://axios-http.com/ is driven by https://github.com/axios/axios-docs. If you find this PR meaningful, I can open another one for the website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr::docs PR that changes project documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify interceptors execution order

1 participant