Skip to content

Request interceptors are called in revers order #5657

@mtnt

Description

@mtnt

Describe the bug

Success and error response interceptors are called in the order they were added (as written in the docs), but response interceptors are called in revers order (the last added is called first).

To Reproduce

https://runkit.com/mtnt/643d3b03c218df000875957b

Code snippet

axios.interceptors.request.use((data) => {
  console.log('request 0');
  
  return data
})

axios.interceptors.request.use((data) => {
  console.log('request 1');
  
  return data
})


axios.interceptors.response.use((data) => {
  console.log('response 0');
  
  return data
})
axios.interceptors.response.use((data) => {
  console.log('response 1');
  
  return data
})


axios.get('https://cdnjs.cloudflare.com/ajax/libs/axios/1.3.5/axios.min.js')

Expected behavior

There should be consoled:
request 0
request 1
response 0
response 1

Axios Version

1.3.5

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

iOS 16

Additional Library Versions

RN 0.71

Additional context/Screenshots

I found it at v0.27 and take an update to 1.3.5 expecting fix. But it still alive.
It can be reproduced at RN and browser (I did not check node)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions