Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error when attempting to iterate through AxiosHeaders class #5452

Closed
podjames opened this issue Jan 9, 2023 · 2 comments
Closed

Type error when attempting to iterate through AxiosHeaders class #5452

podjames opened this issue Jan 9, 2023 · 2 comments

Comments

@podjames
Copy link

podjames commented Jan 9, 2023

Describe the bug

Axios 1.2.2 added Symbol.iterator implementation for the AxiosHeaders class.

However attempting to iterate through the headers class (for example - using Object.fromEntries(headers)) results in a type error.

It looks like Symbol.iterator has been implemented in the code for the AxiosHeaders class but has been missed in the Typescript definitions.

To Reproduce

No response

Code snippet

const headers = new AxiosHeaders({foo: "bar"})

for (const header of headers) {
    console.log(header);
}

error TS2488: Type 'AxiosHeaders' must have a '[Symbol.iterator]()' method that returns an iterator.

Expected behavior

AxiosHeaders class should not throw a type error when attempting to iterate through its properties.

Axios Version

No response

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@bobvandevijver
Copy link

Probably related to #5416.

@podjames
Copy link
Author

podjames commented Feb 3, 2023

Looks like this has been fixed since v1.2.4 - thanks! Will close this 👍

@podjames podjames closed this as completed Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants