status
stringclasses 1
value | repo_name
stringlengths 9
24
| repo_url
stringlengths 28
43
| issue_id
int64 1
104k
| updated_files
stringlengths 8
1.76k
| title
stringlengths 4
369
| body
stringlengths 0
254k
โ | issue_url
stringlengths 37
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[ns, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed
|
axios/axios
|
https://github.com/axios/axios
| 5,028 |
["index.d.ts", "lib/core/AxiosHeaders.js", "test/unit/core/AxiosHeaders.js", "test/unit/regression/bugs.js"]
|
[1.0.0] Set-Cookie header in a response interceptor is not an array anymore
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
In v1, accessing the 'Set-Cookie' header in a response interceptor yields the raw string value of the header.
#### To Reproduce
```js
const axios = require('axios'),
http = require('http');
const server = http
.createServer((req, res) => {
res.setHeader('Set-Cookie', 'my=value');
res.writeHead(200);
res.write('Hi there');
res.end();
})
.listen(0),
request = axios.create();
request.interceptors.response.use((res) => {
console.log(res.headers['set-cookie']);
});
request({ url: `http://localhost:${server.address().port}` }).then(() => server.close());
```
The produces `my=value`
#### Expected behavior
`[ 'my=value' ]`
#### Environment
- Axios Version [e.g. 0.18.0]: 1.0.0
- Adapter [e.g. XHR/HTTP]: http
- Browser [e.g. Chrome, Safari]: N/A
- Browser Version [e.g. 22]: N/A
- Node.js Version [e.g. 13.0.1]: 16.13.0
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]: Ubuntu 20.04
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]: N/A
#### Additional context/Screenshots
N/A
|
https://github.com/axios/axios/issues/5028
|
https://github.com/axios/axios/pull/5085
|
85740c3e7a1fa48346dfcbd4497f463ccb1c1b05
|
110ae9ae613068f4292be9fbd2bf0abf28a6377a
| 2022-10-06T07:38:49Z |
javascript
| 2022-10-13T19:11:01Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 5,015 |
["index.d.ts"]
|
Type definition of AxiosRequestConfig.signal is incompatible to nodejs AbortController.signal
|
Appears in `1.0.0`.
The nodejs TS definition of `AbortController.signal` is:
```typescript
/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
interface AbortSignal {
/**
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
*/
readonly aborted: boolean;
}
```
but Axios 1.0.0 requires:
```typescript
export interface GenericAbortSignal {
aborted: boolean;
onabort: ((...args: any) => any) | null;
addEventListener: (...args: any) => any;
removeEventListener: (...args: any) => any;
}
```
this is incompatible, the event listener messages are missing on the nodejs type definition.
|
https://github.com/axios/axios/issues/5015
|
https://github.com/axios/axios/pull/5021
|
3e4d52171e03f438da36fa726fc828b48a329dcd
|
e757e0e572cecac59db59587bcf00f1b18c2fd10
| 2022-10-05T13:31:53Z |
javascript
| 2022-10-06T06:09:45Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 5,009 |
["index.d.ts", "test/typescript/axios.ts"]
|
Property 'clear' does not exist on type 'AxiosInterceptorManager<AxiosRequestConfig<any>>
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
I tried to use the function added in #4248 with TypeScript, but got the following error.
```
Property 'clear' does not exist on type 'AxiosInterceptorManager<AxiosRequestConfig<any>>
```
#### To Reproduce
Execution is possible, but type checking fails.
```ts
import axios from "axios";
axios.interceptors.request.clear()
```
#### Expected behavior
Successful type check
#### Environment
- Axios 1.0.0
- TypeScript 4.8.4
#### Additional context/Screenshots
|
https://github.com/axios/axios/issues/5009
|
https://github.com/axios/axios/pull/5010
|
e757e0e572cecac59db59587bcf00f1b18c2fd10
|
a6e40c3bb293a3607a327edb78ff5252a5497459
| 2022-10-05T10:41:05Z |
javascript
| 2022-10-06T06:16:27Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 5,001 |
["lib/axios.js"]
|
1.0.0 wrong type definition, class `AxiosError` is not exported
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
class `AxiosError` is exported through axios' property, but type definition says it's exported both way.
#### To Reproduce
install axios 1.0.0 and create `index.ts`, transpile it **without `esModuleInterop`**
```js
import { AxiosError } from "axios";
import * as axios from "axios";
console.log(AxiosError);
console.log(AxiosError == axios.AxiosError);
```
Then run output file:
This will pass typescript's type checking, but raise a error at runtime:
```text
import { AxiosError } from "axios";
^^^^^^^^^^
SyntaxError: The requested module 'axios' does not provide an export named 'AxiosError'
```
This is because ini `index.d.ts`,
https://github.com/axios/axios/blob/484aa4fe6addccbd32206a31eb3d2d000843066e/index.d.ts#L344
this means we have a `export class AxiosError` in our `./dist/esm/axios.js`, but it doesn't, we have only `axios.AxiosError = AxiosError` and `export default axios`,
This is correct in type as in here
https://github.com/axios/axios/blob/484aa4fe6addccbd32206a31eb3d2d000843066e/index.d.ts#L465
#### Expected behavior
A clear and concise description of what you expected to happen.
#### Environment
- Axios Version 1.0.0
- Node.js Version 16.17.1
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/5001
|
https://github.com/axios/axios/pull/5003
|
484aa4fe6addccbd32206a31eb3d2d000843066e
|
d61dbede9578e21f04d5506a79727b3adfe23704
| 2022-10-05T00:12:26Z |
javascript
| 2022-10-05T06:02:35Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 5,000 |
["package.json", "test/module/esm/index.js"]
|
exports lib packages in package.json
|
TLDR๏ผ
> Oh, yeah I don't think we will ever export that.
https://github.com/axios/axios/issues/5000#issuecomment-1311350960
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Is your feature request related to a problem? Please describe.
Yes. I'm writing a adaptor to be used in userscript like tampermonkey or Violentmonkey,
it use a xhr provided be broser extension `GM.xmlHttpRequest` to make cors request.
And to make it behavior like axios' xhr adaptor, I'm using some axios' helper functions directly by
```ts
import buildFullPath from "axios/lib/core/buildFullPath";
import settle from "axios/lib/core/settle";
import buildURL from "axios/lib/helpers/buildURL";
import parseHeaders from "axios/lib/helpers/parseHeaders";
import utils from "axios/lib/utils";
```
But after axios **1.0.0** is released, a `exports` field is added to package.json, and lib directory is no longer exported anymore, this make me unable to use helper function provided by axios anymore.
https://github.com/axios/axios/blob/484aa4fe6addccbd32206a31eb3d2d000843066e/package.json#L6-L17
modern js bundler will raise a error for this: `Package subpath './lib/core/buildFullPath' is not defined by "exports" in .../node_modules/axios/package.json` by bundler.
#### Describe the solution you'd like
add `lib` dir to `package.json#exports`
|
https://github.com/axios/axios/issues/5000
|
https://github.com/axios/axios/pull/5677
|
59eb99183546d822bc27e881f5dcd748daa04173
|
df38c949f26414d88ba29ec1e353c4d4f97eaf09
| 2022-10-04T23:40:56Z |
javascript
| 2023-04-25T21:17:21Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,999 |
["lib/adapters/http.js", "test/unit/regression/bugs.js"]
|
After upgrade to 1.0 GET request with parameters in the url fail
|
Working request with Axios v1.0.0-alpha.1:
```
axios.get('https://git.somegit.com/api/v3/search/commits?q=sort:committer-date-desc merge:false repo:org/reponame&per_page=50&page=1
```
Same request with 1.0.0 fails with a 404. 1.0.0 was promoted today.
When I print the failed response it looks like something is parsed/encoded incorrectly.
```
request: <ref *1> ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
.....
.....
_headerSent: true,
socket: [TLSSocket],
_header: 'GET /api/v3/search/commitsq=sort%3Acommitter-date-desc+merge%3Afalse+repo%3Aorg%2Freponame&per_page=50&page=1 HTTP/1.1\r\n' +
'Accept: application/vnd.github.cloak-preview+json;application/vnd.github.v3+json\r\n' +
'User-Agent: axios/1.0.0\r\n' +
'Accept-Encoding: gzip, deflate, br\r\n' +
'Host: git.somegit.com\r\n' +
'Connection: close\r\n' +
'\r\n',
```
To me the `?` is missing in between `commits` and `q`.
When I don't parse the parameters on the URL and use `config.params` it works with Axios `1.0.0`.
```
config.params = {
q: `sort:committer-date-desc merge:false repo:org/reponame`,
per_page: 50,
page: 1
}
```
The success response then shows this `_header`:
```
_header: 'GET /api/v3/search/commits?q=sort:committer-date-desc+merge:false+repo:org%2Freponame&per_page=50&page=1 HTTP/1.1\r\n' +
'Accept: application/vnd.github.cloak-preview+json;application/vnd.github.v3+json\r\n' +
'User-Agent: axios/1.0.0\r\n' +
'Accept-Encoding: gzip, deflate, br\r\n' +
'Host: git.somegit.com\r\n' +
'Connection: close\r\n' +
'\r\n',
```
In the working version I do see the `?`.
So right now the workaround is either sticking with v1.0.0-alpha.1 or using config.params instead of passing them with the .get call.
|
https://github.com/axios/axios/issues/4999
|
https://github.com/axios/axios/pull/5018
|
d61dbede9578e21f04d5506a79727b3adfe23704
|
3e4d52171e03f438da36fa726fc828b48a329dcd
| 2022-10-04T23:28:57Z |
javascript
| 2022-10-05T19:29:50Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,940 |
["README.md"]
|
The documentation for the Axios Get Example shows the .then() method instead of the .finally() method
|
<!-- Click "Preview" for a more readable version --
If you found an area that needs clarification, feel free to open a PR or list the section/content that could be improved below
Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to refer to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Section/Content To Improve
Quote or link to section
https://axios-http.com/docs/example
```
const axios = require('axios').default;
// Make a request for a user with a given ID
axios.get('/user?ID=12345')
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
// Optionally the request above could also be done as
axios.get('/user', {
params: {
ID: 12345
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
.then(function () {
// always executed
});
```
#### Suggested Improvement
Identify what is confusing or incorrect and what could make it better
In accordance with correct syntax, get example should have .finally instead of .then
|
https://github.com/axios/axios/issues/4940
|
https://github.com/axios/axios/pull/4942
|
5138c302bb98b4ea0a34fb03bf067c8219058ffd
|
892c241773e7dda78a969ac1faa9b365e24f6cc8
| 2022-09-03T18:08:36Z |
javascript
| 2022-09-15T05:36:31Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,873 |
["index.d.ts", "test/typescript/axios.ts"]
|
`use` method on `AxiosInterceptorManager` should not be generic
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
The `use` method on AxiosInterceptorManager is defined as a generic method, allowing the caller to return an object (or void) which throws an error at runtime.
```typescript
export interface AxiosInterceptorManager<V> {
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;
// ^ this generic type parameter allows the caller to return _anything_
}
```
#### To Reproduce
The type definition allows a caller to write this:
```typescript
axios.interceptors.request.use((req) => {
console.log("returning void from interceptor for request:", req.url)
})
const res = await axios.get("https://httpbin.org/get")
console.log("received:", res.data.url)
```
This type checks successfully but throws at runtime with the following exception:
```
TypeError: Cannot read properties of undefined (reading 'cancelToken')
at throwIfCancellationRequested (/home/runner/UnwieldyAdeptArchitect/node_modules/axios/lib/core/dispatchRequest.js:13:14)
at dispatchRequest (/home/runner/UnwieldyAdeptArchitect/node_modules/axios/lib/core/dispatchRequest.js:29:3)
at null.go (/home/runner/UnwieldyAdeptArchitect/index.ts:7:15)
```
#### Expected behavior
Since request interceptors must return the config object, TypeScript should emit error TS2345:
> Argument of type '(res: AxiosRequestConfig) => void' is not assignable to parameter of type '(res: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>'
Similarly, if a response interceptor returns void, the same TypeScript error should be emitted telling the caller to return an `AxiosResponse` (or `Promise<AxiosResponse>`)
#### Environment
- Axios Version 0.27.2
- Node.js Version 16.13.2
- TypeScript Version 4.4.4
- Running on Repl.it
#### Additional context/Screenshots
I believe the generic type parameter should simply be removed from the `use` method, and any `T` replaced with `V`:
```typescript
export interface AxiosInterceptorManager<V> {
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;
eject(id: number): void;
}
```
This type is used like so, which already allows for returning any type of `AxiosResponse` from the onFulfilled callback:
```typescript
interceptors: {
request: AxiosInterceptorManager<AxiosRequestConfig>; // implicitly AxiosRequestConfig<any>
response: AxiosInterceptorManager<AxiosResponse>; // implicitly AxiosResponse<any>
}
```
Removing the generic type would mean these methods have the following signatures:
```typescript
export class Axios {
interceptors: {
request: {
use(onFulfilled: (value: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>, /* ... */): number,
// ...
},
response: {
use(onFulfilled: (value: AxiosResponse) => AxiosResponse| Promise<AxiosResponse>, /* ... */): number,
// ...
}
}
}
```
|
https://github.com/axios/axios/issues/4873
|
https://github.com/axios/axios/pull/4874
|
b0710bf8a2fbb10992c7dc60a5ceb6e1bc8d4929
|
64906bd8866fd86369133cee461f75b8353176ba
| 2022-07-21T22:12:33Z |
javascript
| 2022-09-26T19:11:29Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,737 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
The timeoutErrorMessage property in config not work with Node.js
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
Upgrading from 0.26.1 to 0.27.2 cause:
The timeoutErrorMessage property in config not work with Node.js, expected custom error message, got "timeout of *ms exceeded"
note: #3580 is a merged/closed issue with the same exact problem
#### To Reproduce
```ts
import axios from 'axios';
import nock from 'nock';
const axiosInstance = axios.create({
timeout: 5000,
timeoutErrorMessage: 'Custom Timeout Error Message',
});
describe('test axios', () => {
it('should respect the timeoutErrorMessage property', async () => {
nock('http://localhost:4444/')
.get('/test')
.delayConnection(6000)
.reply(200);
const axprom = axiosInstance.get('http://localhost:4444/test');
await expect(axprom).rejects.toThrow('Custom Timeout Error Message');
}, 10000);
});
```
#### Expected behavior
Expected: Custom Timeout Error Message
Got: timeout of 5000ms exceeded
#### Environment
- Axios Version: 0.27.2
- Adapter: nock
- Browser: n/a
- Browser Version : n/a
- Node.js Version: 16.13.1
- OS: macOS 11.6
- Additional Library Versions: n/a
#### Additional context/Screenshots

|
https://github.com/axios/axios/issues/4737
|
https://github.com/axios/axios/pull/4738
|
9bb016f95e6de871a44f3276fd06562704a0abb0
|
a11f9501b823a167de7187ee542e4204ad1a517a
| 2022-05-24T07:44:31Z |
javascript
| 2022-05-28T09:46:33Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,727 |
[".github/workflows/ci.yml", "bin/ssl_hotfix.js", "lib/helpers/fromDataURI.js", "lib/helpers/toFormData.js", "package-lock.json", "package.json", "test/unit/adapters/http.js", "test/unit/helpers/fromDataURI.js"]
|
postForm fails with "source.on is not a function" when using Buffer or Uint8Array in Node 18
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the issue
Passing Uint8Array or Buffer to postForm results in "source.on is not a function" exception.
#### Example Code
```js
const data = Uint8Array.from([1, 2, 3])
axios.postForm('http://some.url', { data })
// or
const data = Uint8Array.from([1, 2, 3])
axios.postForm('http://some.url', { data: Buffer.from(data) })
```
#### Expected behavior, if applicable
axios should POST a field "data" with the content of the Uint8Array / Buffer
#### Environment
- Axios Version 0.27.2
- Node.js Version 18.2.0
- OS: Windows 11
#### Additional context/Screenshots
Code is compiled from TypeScript using typescript 4.6.4 and a tsconfig.json that extends @tsconfig/node18/tsconfig.json
I am trying to upload the PDF output of puppeteer.
What am I doing wrong?
|
https://github.com/axios/axios/issues/4727
|
https://github.com/axios/axios/pull/4728
|
de973f00f312080fb0dd0dc3b9cbe72c88b3da61
|
467025bdb743d0132ee236a7c935b9ac14f5408f
| 2022-05-18T15:22:55Z |
javascript
| 2022-05-20T14:31:26Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,713 |
["lib/core/AxiosError.js"]
|
AxiosError does not include stack trace (`stack` property)
|
Version 0.26.1 of axios created errors by calling `new Error()`, and then augmenting it. Doing it this way, the error object contained a `stack` property with the stack trace.
With version 0.27, axios creates errors as an Object, and doesn't add the `stack` property to them, so there's no stack trace available.
Expected behavior is that there will be a `stack` property with a stack trace.
The issue is that the constructor for `AxiosError` does `Error.call(this);`, but that doesn't add a stack trace property. Adding the stack trace needs to be done after that using code like:
```
// Use V8's native method if available, otherwise fallback
if ("captureStackTrace" in Error)
Error.captureStackTrace(this, InvalidArgumentException);
else
this.stack = (new Error()).stack;
```
See my stack overflow article https://stackoverflow.com/questions/464359/custom-exception-type/27724419#27724419 for more info.
I can submit a PR if you guys agree on the technique.
Thanks!
|
https://github.com/axios/axios/issues/4713
|
https://github.com/axios/axios/pull/4718
|
65b92958ae4f4838646797d1468b86990bd49e83
|
d60d6844b15204a87c96ad289cb502a9647ed6cc
| 2022-05-13T20:41:25Z |
javascript
| 2022-05-16T06:58:47Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,703 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
Using config.beforeRedirect prevents using proxy on redirected requests
|
#### Describe the bug
The support for `config.beforeRedirect` introduced a regression of https://github.com/axios/axios/issues/3369 when both `config.beforeRedirect` and a proxy are used. Both of them internally set `options.beforeRedirect`. Moreover, `config.beforeRedirect` is not re-applied on subsequent redirections.
#### To Reproduce
Adding the following test in `test/unit/adapters/http.js`
```js
it('should support beforeRedirect and proxy with redirect', function (done) {
var requestCount = 0;
var totalRedirectCount = 5;
server = http.createServer(function (req, res) {
requestCount += 1;
if (requestCount <= totalRedirectCount) {
res.setHeader('Location', 'http://localhost:4444');
res.writeHead(302);
}
res.end();
}).listen(4444, function () {
var proxyUseCount = 0;
proxy = http.createServer(function (request, response) {
proxyUseCount += 1;
var parsed = url.parse(request.url);
var opts = {
host: parsed.hostname,
port: parsed.port,
path: parsed.path
};
http.get(opts, function (res) {
response.writeHead(res.statusCode, res.headers);
res.on('data', function (data) {
response.write(data)
});
res.on('end', function () {
response.end();
});
});
}).listen(4000, function () {
var configBeforeRedirectCount = 0;
axios.get('http://localhost:4444/', {
proxy: {
host: 'localhost',
port: 4000
},
maxRedirects: totalRedirectCount,
beforeRedirect: function (options) {
configBeforeRedirectCount += 1;
}
}).then(function (res) {
assert.equal(totalRedirectCount, configBeforeRedirectCount, 'should invoke config.beforeRedirect option on every redirect');
assert.equal(totalRedirectCount + 1, proxyUseCount, 'should go through proxy on every redirect');
done();
}).catch(done);
});
});
});
```
#### Expected behavior
The test should pass, but currently 'should go through proxy on every redirect' assertion fails.
#### Environment
- Axios Version `0.27.2`
- Adapter `HTTP`
- Browser `N/A`
- Browser Version `N/A`
- Node.js Version `N/A`
- OS: `N/A`
- Additional Library Versions `N/A`
#### Additional context/Screenshots
I'm working on a small PR to fix this issue.
|
https://github.com/axios/axios/issues/4703
|
https://github.com/axios/axios/pull/4708
|
13dd93f6c54abb6e15ee5f97d5fb3a287dc42058
|
24f22b2b0bc93fc1a0b2ab0fab1c803c05aa2963
| 2022-05-10T15:35:38Z |
javascript
| 2022-05-16T06:05:56Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,698 |
["README.md", "index.d.ts", "lib/defaults/index.js", "lib/helpers/toFormData.js", "lib/utils.js", "package-lock.json", "package.json", "test/specs/helpers/toFormData.spec.js", "test/unit/adapters/http.js"]
|
toFormData should (optionally?) support array serialization (w/o [] suffix)
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Is your feature request related to a problem? Please describe.
While trying to migrate to the new FormData autogeneration (by using postForm or setting Content-Type to multipart) I realized arrays won't work anymore. An 'arr' proprety with two entries will be converted to name="arr.0" and name="arr.1" in the payload.
I saw in the source-code that once the name has a suffix like '[]' it will post it as such. But our springboot backend wants the key to be 'arr' (not 'arr[]') and our client-side typescript interface has a key named 'arr' and not 'arr[]' either.
#### Describe the solution you'd like
Plain arrays should also be send automatically, without the need to put '[]' to its name. If that's a breaking change, make it optional via options.
#### Describe alternatives you've considered
Springboot can't parse the default 'arr.0', 'arr.1' format. And adding '[]' to the type, the client-side object and the desired property in the backend is not an ideal solution.
In typescript properties of types/interfaces usually don't have a '[]' suffix. But the whole point of migrating to this new feature is to have type-safe services with a typed payload instead of just any 'FormData' object.
#### Additional context
|
https://github.com/axios/axios/issues/4698
|
https://github.com/axios/axios/pull/4704
|
495d5fb1333f2cb0c7e49ecfd6470dd1700ca96c
|
807918bda2768df0f3a3422abd4e30d16694092d
| 2022-05-09T15:48:35Z |
javascript
| 2022-05-11T17:30:08Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,684 |
["index.d.ts"]
|
AxiosError has status defined as string but it is really number
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
Type definition for AxiosError is incorrect. The definition was introduced in this commit:
https://github.com/axios/axios/pull/3645/files#diff-7aa4473ede4abd9ec099e87fec67fd57afafaf39e05d493ab4533acc38547eb8R137
When you look at the actual runtime payload it has a number type. For example, a 401 error has `status` of `401` not `"401"` when you `JSON.stringify(error)`.
#### To Reproduce
A code snippet really doesn't make sense here, but you can see the JSON object that was constructed from the error object in the case that I observed.
```json
{
"message": "Request failed with status code 401",
"name": "AxiosError",
"config": {
"transitional": {
"silentJSONParsing": true,
"forcedJSONParsing": true,
"clarifyTimeoutError": false
},
"transformRequest": [null],
"transformResponse": [null],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1,
"env": {},
"headers": {
"Accept": "application/json",
"Cache-Control": "no-cache",
"Content-Type": "no-cache",
"User-Agent": "axios/0.27.2"
},
"method": "get",
"url": "https://somedomainrequiringauth.com/some-endpoint-requiring-auth"
},
"code": "ERR_BAD_REQUEST",
"status": 401
}
```
#### Expected behavior
The definition should be a number.
#### Environment
- Axios Version 0.27.2
- Adapter HTTP
- Browser N/A
- Browser Version N/A
- Node.js Version v16.14.2
- OS: OSX 12.2.1
- Additional Library Versions N/A
#### Additional context/Screenshots
N/A
|
https://github.com/axios/axios/issues/4684
|
https://github.com/axios/axios/pull/4717
|
9be61dc1c9a84085a0a2ac80500034aa9418d57c
|
65b92958ae4f4838646797d1468b86990bd49e83
| 2022-05-06T01:07:48Z |
javascript
| 2022-05-16T06:51:22Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,677 |
["lib/adapters/xhr.js"]
|
blob: urls rejected
|
#### Describe the bug
axios throws ERR_BAD_REQUEST (message: Unsupported protocol blob:) when processing a url with scheme blob:
#### To Reproduce
This code:
```js
const blob = new Blob(["some content"]);
const url = URL.createObjectURL(blob);
const response = await axios.get(url, {responseType: "blob"});
```
generates a blob url (eg, blob:http://localhost:3001/01296a6c-a41f-49b1-b59e-af71729dbb6b) which axios rejects as having an invalid scheme. But the browser supports such urls and it was working alright until https://github.com/axios/axios/pull/3544 which started restricting the schemes accepted.
#### Expected behavior
Accept the request.
#### Environment
- Browser
- axios 0.26.1 and later.
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/4677
|
https://github.com/axios/axios/pull/4678
|
2f50c8249bba77a34eb7d14e3274ed560c2f2e91
|
356b166182de33936c8581df1637894f06d9f386
| 2022-05-05T03:25:28Z |
javascript
| 2022-05-09T17:27:18Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,655 |
["lib/adapters/xhr.js"]
|
AxiosError ERR_NETWORK contains request as response
|
#### Describe the bug
When performing an axios request which is rejected with `ERR_NETWORK` the created `AxiosError` contains the request as response.
This leads to the issue that the response of the `AxiosError` contains the status code 200 and the body of the request although in reality no response was received.
I think the issue is that the request is passed as 5th parameter (response) of the `AxiosError` constructor here:
https://github.com/axios/axios/blob/bc733fec78326609e751187c9d453cee9bf1993a/lib/adapters/xhr.js#L119
#### To Reproduce
Sample project:
[sample.zip](https://github.com/axios/axios/files/8588127/sample.zip)
Running the sample project with `npm run test` prints the following to the console:
```
error code: ERR_NETWORK
response status: 200
response body: {"foo":"bar"}
```
#### Expected behavior
The response field in the `AxiosError` created due to `ERR_NETWORK` should be undefined.
#### Environment
- Axios Version 0.27.2
- Adapter XHR
- Browser -
- Browser Version -
- Node.js Version 18.0.0
- OS: macOS 12.3.1
- Additional Library Versions msw: ^0.39.2
#### Additional context/Screenshots
NA
|
https://github.com/axios/axios/issues/4655
|
https://github.com/axios/axios/pull/4656
|
bc733fec78326609e751187c9d453cee9bf1993a
|
12faca87e0fceb25faba33ca9a5bd603f3a7a75e
| 2022-04-29T04:21:21Z |
javascript
| 2022-05-03T16:30:17Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,653 |
["index.d.ts", "test/typescript/axios.ts"]
|
Write toFormData types
|
#### Is your feature request related to a problem? Please describe.
I want to use new toFormData method, but it is not typed in index.d.ts
#### Describe the solution you'd like
Add types for toFormData
#### Describe alternatives you've considered
Use ts-ignore
#### Additional context
None
|
https://github.com/axios/axios/issues/4653
|
https://github.com/axios/axios/pull/4668
|
e52af17ee8d4e50a1e34b3148aaf8499a15df59c
|
c07998a62126256e2a0fad53bc3abc050f60c0c1
| 2022-04-28T13:12:19Z |
javascript
| 2022-05-03T18:29:50Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,633 |
["lib/adapters/xhr.js", "lib/helpers/parseProtocol.js", "test/unit/helpers/parseProtocol.js"]
|
Unexpected 'Unsupported protocol' error for relative URLs containing colon (:) character
|
#### Describe the bug
For some REST API endpoints we use [Google Cloud API Custom Methods](https://cloud.google.com/apis/design/custom_methods) URL design like `/api/resource:customVerb`.
These worked with `axios` prior to **0.27.1** but now they result in an error like:
`AxiosError { message: "Unsupported protocol /api/resource:', code: "ERR_BAD_REQUEST", ... }`
#### To Reproduce
Try to have `axios` get a relative URL with a colon in it, e.g.
```js
axios.get("/api/resource:customVerb");
```
#### Expected behavior
Should continue working as it did before version **0.27.1**.
#### Environment
- Axios Version: 0.27.1
- Browser: Microsoft Edge 100.0.1185.50
- Node.js Version: 16.14.2
- OS: Windows 10 Pro
#### Additional context/Screenshots
n/a
|
https://github.com/axios/axios/issues/4633
|
https://github.com/axios/axios/pull/4639
|
76432c18bee20e2cbd9e673af8a3bf43641ad115
|
b9e9fb4fa0ab1e0f4bc9ac8d8cf493f5f8507dc3
| 2022-04-26T12:55:07Z |
javascript
| 2022-04-27T09:30:50Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,623 |
["lib/adapters/http.js"]
|
axios v0.27.0 uses node polyfills provided by webpack, which are removed from webpack v5
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
I'm using axios in an app created by create-react-app. As soon I upgraded axios to v0.27.0, the application stop working with the error shown in the reproduction section. Downgrading to v0.26.1 solved the issue.
It looks like the issues rises from the xhr adapter.
#### To Reproduce
Create an empty project using CRA
```shell
npx create-react-app my-app
cd my-app
```
install axios
```shell
npm install axios
```
use axios to make any request
```js
useEffect(() => {
axios.get("https://google.com");
}, []);
```
start the application
```shell
npm start
```
The error is shown in the console
```shell
Module not found: Error: Can't resolve 'url' in '/home/mayo/personal-projects/my-app/node_modules/axios/lib/adapters'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
- install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "url": false }
ERROR in ./node_modules/axios/lib/adapters/xhr.js 17:10-24
Module not found: Error: Can't resolve 'url' in '/home/mayo/personal-projects/my-app/node_modules/axios/lib/adapters'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
- install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "url": false }
webpack compiled with 1 error
```
#### Expected behavior
That it works, or at least there are instruction to install the dependencies in the documentation.
#### Environment
- Axios Version 0.27.0
- Additional Library Versions create-react-app (react-scripts) v5 / webpack v5
#### Additional context/Screenshots
None
|
https://github.com/axios/axios/issues/4623
|
https://github.com/axios/axios/pull/4715
|
c05ad4895293ac8e0bbb90b28e0772571a97cdd5
|
9be61dc1c9a84085a0a2ac80500034aa9418d57c
| 2022-04-25T19:14:11Z |
javascript
| 2022-05-16T06:46:46Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,616 |
["lib/core/dispatchRequest.js", "test/specs/transform.spec.js"]
|
content-type application/x-www-form-urlencoded repeated
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
when 'content-type' is in lowercase๏ผ
Devtool Network show :Content-Type: application/x-www-form-urlencoded, application/x-www-form-urlencoded๏ผ
that is repeated.
#### To Reproduce
Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue. **If your problem is not reproducible, please file under Support or Usage Question**
```js
axios({
method: 'post',
url: 'http://yapi.corp.lanyicj.cn/mock/228/stock_trade/user_account',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
transformRequest: [
function () {
return 'aa=44'
}
]
})
```
#### Expected behavior
Content-Type: application/x-www-form-urlencoded
#### Environment
- Axios Version [e.g. 0.18.0]
- Adapter [e.g. XHR/HTTP]
- Browser [e.g. Chrome, Safari]
- Browser Version [e.g. 22]
- Node.js Version [e.g. 13.0.1]
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/4616
|
https://github.com/axios/axios/pull/4745
|
a11f9501b823a167de7187ee542e4204ad1a517a
|
1504792765a89bfe5b07041979a86218cace9c6d
| 2022-04-25T11:56:30Z |
javascript
| 2022-05-28T09:52:50Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,610 |
[".eslintrc.cjs", "lib/adapters/http.js", "lib/env/classes/FormData.js", "lib/helpers/formDataToStream.js", "lib/helpers/readBlob.js", "lib/helpers/toFormData.js", "lib/utils.js", "package.json", "test/unit/adapters/http.js"]
|
Support other FormData implementations
|
#### Is your feature request related to a problem? Please describe.
It's related to the problem of sending `multipart/form-data` with Axios on Node.js
#### Describe the solution you'd like
I would like to be able to do
```js
const axios = require('axios');
const { FormData } = require('formdata-node');
const form = new FormData();
axios.post('http://localhost:8888', form)
```
#### Describe alternatives you've considered
N/A
#### Additional context
`got` [recommends](https://github.com/sindresorhus/got/blob/e3936629ce8b075749f33260b8cf036c7832e448/documentation/2-options.md#body) using [`formdata-node`](https://www.npmjs.com/package/formdata-node). Axios [recommends](https://axios-http.com/docs/urlencoded#form-data) [`form-data`](https://www.npmjs.com/package/form-data).
I would like to use `formdata-node` with both because I want to use both `got` and Axios and I don't want people reading the code to need to notice that there's two different libraries used for `FormData`. Also `formdata-node` has a table saying that `form-data`'s `FormData` doesn't have a bunch of methods that the browser's does. I tried using `formdata-node` with Axios
```sh
cd /tmp
mkdir axios-form-test
cd axios-form-test
npm init -y
npm install axios
npm install formdata-node
node
```
```js
const axios = require('axios');
const { FormData } = require('formdata-node');
const form = new FormData();
form.append('my_field', 'my value');
form.append('my_other_field', 'my second value');
axios.post('http://localhost:8888', form)
```
and got an error
```none
Uncaught:
Error: Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream
at createError (/private/tmp/axios-test/node_modules/axios/lib/core/createError.js:16:15)
at dispatchHttpRequest (/private/tmp/axios-test/node_modules/axios/lib/adapters/http.js:98:23)
at new Promise (<anonymous>)
at httpAdapter (/private/tmp/axios-test/node_modules/axios/lib/adapters/http.js:48:10)
at dispatchRequest (/private/tmp/axios-test/node_modules/axios/lib/core/dispatchRequest.js:58:10)
at Axios.request (/private/tmp/axios-test/node_modules/axios/lib/core/Axios.js:108:15)
at Axios.<computed> [as post] (/private/tmp/axios-test/node_modules/axios/lib/core/Axios.js:140:17)
at Function.wrap [as post] (/private/tmp/axios-test/node_modules/axios/lib/helpers/bind.js:9:15) {
config: { [...]
```
|
https://github.com/axios/axios/issues/4610
|
https://github.com/axios/axios/pull/5316
|
65e8d1e28ce829f47a837e45129730e541950d3c
|
6ac574e00a06731288347acea1e8246091196953
| 2022-04-21T23:57:24Z |
javascript
| 2023-01-30T23:10:39Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,588 |
["lib/adapters/http.js", "lib/adapters/xhr.js"]
|
optimazition of code
|
#### Is your feature request related to a problem? Please describe.
This is an optimazition of code.
#### Describe the solution you'd like
The following line of code comes from https://github.com/axios/axios/blob/master/lib/adapters/http.js#L403:
```js
reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
```
It can be optimized as follows:
```js
reject(!cancel || cancel.type ? new CanceledError() : cancel);
```
#### Describe alternatives you've considered
When the code is executed to `(cancel && cancel.type)`, it means `!cancel` is false, so `cancel` is true, we can get `cancel.type` directly.
#### Additional context
no more
|
https://github.com/axios/axios/issues/4588
|
https://github.com/axios/axios/pull/4587
|
e9efc69f684b7100ee1de49a5178a6b4ca85949f
|
e52af17ee8d4e50a1e34b3148aaf8499a15df59c
| 2022-04-06T14:41:21Z |
javascript
| 2022-05-03T17:04:58Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,486 |
["lib/core/AxiosError.js", "lib/utils.js", "test/unit/utils/utils.js"]
|
Error.toJSON() should exclude httpsAgent
|
#### Describe the bug
if the `httpsAgent` property is set, it is not excluded from `error.toJSON()` resulting in a circular reference error
```none
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'httpsAgent' -> object with constructor 'Agent'
| property 'sockets' -> object with constructor 'Object'
| ...
| property 'errored' -> object with constructor 'Object'
--- property 'config' closes the circle
at JSON.stringify (<anonymous>)
```
#### To Reproduce
```js
const agent = new https.Agent({
rejectUnauthorized: false
});
axios.get("some-dodgy-url", {
httpsAgent: agent
}).catch((err) => {
console.error(err.toJSON())
})
```
#### Expected behavior
The error object should be serialisable as JSON without throwing circular reference errors.
#### Environment
- Axios 0.26.0
#### Additional context/Screenshots
See [this StackOverflow post](https://stackoverflow.com/q/71150003/283366)
|
https://github.com/axios/axios/issues/4486
|
https://github.com/axios/axios/pull/5247
|
a372b4ce4b8027faf1856b3a2a558ce582965864
|
b7ee49f63731a914a62bec5768af4b67b7a3f841
| 2022-02-17T01:59:39Z |
javascript
| 2022-11-22T18:44:24Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,406 |
["index.d.ts", "lib/adapters/http.js", "lib/defaults.js", "lib/helpers/toFormData.js", "lib/utils.js", "test/specs/helpers/toFormData.spec.js"]
|
Can't post FormData since Axios 0.25.0
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the issue
I can't post FormData since `"axios": "^0.25.0",`
`Error: Request failed with status code 400`
#### Example Code
```js
export const client = axios.create({
baseURL: URL_API,
withCredentials: true,
responseType: 'json',
timeout: 30000,
});
const params = new FormData();
params.append('name', data.model);
params.append('idFuel', data.idFuel);
params.append('power', data.idPower);
client.post(`/app/society/${idSociety}/vehicle`, params, { headers: { "Content-Type": "multipart/form-data" } })
```
#### Expected behavior, if applicable
That it works
#### Environment
- Axios Version: 0.25.0
- Node.js Version: v14.17.6
- OS: iOS 15, Android 11 (But on all platforms and versions)
- Additional Library Versions: React Native 0.64.3
#### Additional context/Screenshots
No problem with `"axios": "^0.24.0",`
I saw this PR https://github.com/axios/axios/pull/3757 on 0.25.0, but I don't know what I have to change in code.
Thanks for your help ๐
|
https://github.com/axios/axios/issues/4406
|
https://github.com/axios/axios/pull/4413
|
cc86c6c49fdbfd8e2517b191b8833d2f2816ff91
|
73e3bdb8835ba942096b662e9441f1d85ce4d484
| 2022-01-19T13:36:37Z |
javascript
| 2022-02-02T11:48:44Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,335 |
["index.d.ts"]
|
Incomplete typings for AxiosRequestHeaders
|
#### Describe the bug
`AxiosRequestHeaders` is currently only a `Record` for primitives `Record<string, string | number | boolean>` and, according to typing cannot have object as values. In reality, headers under keys can objects with other keys. A good example is from README:
```
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
```
#### To Reproduce
F.e. if we were to delete a header entry in `transformRequest` we would get a typescript error `Property 'Authorization' does not exist on type 'string'.`
```js
return axios({
method : 'get',
transformRequest: (data, headers) => {
delete headers?.common?.Authorization;
}
})
```
#### Expected behavior
To be able to access / delete headers under the whole list of keys common, post, etc
#### Environment
- Axios Version 0.24.0
- Adapter HTTP
#### Additional context/Screenshots
This is a typescript bug
|
https://github.com/axios/axios/issues/4335
|
https://github.com/axios/axios/pull/4334
|
ee51e6814320700da03eb8ed62231e31c2557b1e
|
e6f9026d51d5e1386bc6935e563d95c375c45d02
| 2021-12-17T10:48:22Z |
javascript
| 2022-05-16T07:33:36Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,324 |
[".gitignore"]
|
Package-lock.json file should be committed
|
#### Describe the issue
The file package-lock.json should not be in the .gitignore file.
The main purpose of package-lock.json is to guarantee that all contributors install exactly the same dependencies.
The npm website explicitly says that this file is to be commited in the source.
> This file is intended to be committed into source repositories, and serves various purposes:
>
> - Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
>
> - Provide a facility for users to "time-travel" to previous states of node_modules without having to commit the directory itself.
>
> - Facilitate greater visibility of tree changes through readable source control diffs.
>
> - Optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages.
>
> - As of npm v7, lockfiles include enough information to gain a complete picture of the package tree, reducing the need to read package.json files, and allowing for significant performance improvements.
[https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json](url)
I have read the issues #1458 but I do not agree with it. From my understanding, in the package-lock each dependencies have its dependencies version. So if a dependency is used in several dependencies with different versions, the good version will be used for each dependency.
#### Example Code
.
#### Expected behavior, if applicable
.
#### Environment
.
#### Additional context/Screenshots
.
|
https://github.com/axios/axios/issues/4324
|
https://github.com/axios/axios/pull/4346
|
ea0d9c69f78070dae841c66efd7263e246cab845
|
ccc9516af8b762c51efd8ca1d326a63b9de76a41
| 2021-12-13T23:44:42Z |
javascript
| 2021-12-29T05:30:54Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,263 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
Unexpected default `maxBodyLength` enforcement by `follow-redirects`
|
#### Describe the bug
As part of the upgrade of `follow-redirects` in https://github.com/axios/axios/pull/2689, a default `maxBodyLength` of 10MB began to be enforced (previously, there was no request payload limit). There are a few issues with this:
1. The default limit is not mentioned in the `axios` documentation
2. This change in defaults is not included as a breaking change in the `axios` changelog
3. The default is unlimited when `maxRedirects = 0`
#### To Reproduce
```js
axios.post('/size', 'x'.repeat(1e8))
// -> Error: Request body larger than maxBodyLength limit
axios.post('/size', 'x'.repeat(1e8), { maxBodyLength: -1 })
// -> Error: Request body larger than maxBodyLength limit
axios.post('/size', 'x'.repeat(1e8), { maxRedirects: 0 })
// -> OK
axios.post('/size', 'x'.repeat(1e8), { maxBodyLength: Infinity })
// -> OK
```
#### Expected behavior
The default `maxBodyLength` should be consistent and documented, regardless of the value of `maxRedirects`.
#### Environment
- Axios Version: 0.24.0
- Adapter: HTTP
- Browser: N/A
- Browser Version: N/A
- Node.js Version: 16.13.0
- OS: OS X 11.6
- Additional Library Versions: N/A
#### Additional context/Screenshots
This is related to https://github.com/axios/axios/pull/3786, although I don't think that PR goes far enough to correct the inconsistent behavior.
|
https://github.com/axios/axios/issues/4263
|
https://github.com/axios/axios/pull/4731
|
c30252f685e8f4326722de84923fcbc8cf557f06
|
e9c9f3392b4a31e24b2bcb8399639de624a24386
| 2021-11-13T02:23:41Z |
javascript
| 2022-05-20T06:27:37Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,260 |
["lib/cancel/CancelToken.js", "test/unit/adapters/http.js"]
|
Race condition on immediate requests cancellation (a solution is suggested)
|
#### Describe the bug
Axios throws an error instead of canceling all requests when I try to cancel multiple requests just after sending them.

#### To Reproduce
[Code snippet to reproduce on npm.runkit.com](https://runkit.com/korniychuk/618e792c131c100008191c5e)
```js
var axios = require("axios");
const CancelToken = axios.CancelToken;
const source = CancelToken.source();
const promises = Array(5).fill(1).map((v, i) =>
axios.get('https://www.google.com', { cancelToken: source.token })
.catch(e => axios.isCancel(e) && console.log(`Req ${ i } is cancelled ${ e && e.message }`))
);
source.cancel('Aborted by user');
await Promise.all(promises);
console.log('Done');
```
#### Expected behavior
Should cancel all requests without throwing an error.
#### Environment
- Axios Version [0.24.0]
- Adapter [default maybe, I don't know]
- Browser [NA]
- Browser Version [NA]
- Node.js Version [16.13]
- OS: [*]
- Additional Library Versions [no libraries]
#### Additional context/Screenshots
I've described the issue with the screenshot.

#### Solution
<img width="1238" alt="Ankor 2021-11-12 at 16 43 30@2x" src="https://user-images.githubusercontent.com/11693557/141485034-667c62cf-5084-4c27-812b-9108e3c1d8cb.png">
```js
this.promise.then(function(cancel) {
if (!token._listeners) return;
var i;
var l = token._listeners.length;
/** We have to clone it to avoid a race condition with .unsubscribe() method */
var clonedListenersArr = token._listeners.concat();
for (i = 0; i < l; i++) {
clonedListenersArr[i](cancel);
}
token._listeners = null;
});
```
Maybe someone has time to create a simple PR. It would be great.
|
https://github.com/axios/axios/issues/4260
|
https://github.com/axios/axios/pull/4261
|
27280ec260bb353b57807ebcf8aa30b772663405
|
de48c5d626e056d5e6056099c881b878103fc20e
| 2021-11-12T14:44:46Z |
javascript
| 2022-05-09T16:12:29Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,223 |
["index.d.ts"]
|
unable to set response type on instance method
|
#### Describe the bug
When configuring the request method through the config object and using the axios instance method, we cannot define the response type returned by the request.
#### To Reproduce
In version `0.22` I used the following code:
```typescript
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
const config: AxiosRequestConfig = {
method: 'get',
url: 'https://api.github.com/users/jelleschutter/repos?per_page=1'
}
type RepositoryModel = {
full_name: string;
description: string;
}
axios(config).then((res: AxiosResponse<RepositoryModel[]>) => {
console.log(res.data);
});
```
Which leads to the following error in `0.23`:
```
TS2345: Argument of type '(res: AxiosResponse<RepositoryModel[]>) => void' is not assignable to parameter of type '(value: AxiosResponse<unknown, any>) => void | PromiseLike<void>'.
Types of parameters 'res' and 'value' are incompatible.
Type 'AxiosResponse<unknown, any>' is not assignable to type 'AxiosResponse<Repository[], any>'.
Type 'unknown' is not assignable to type 'Repository[]'.
14 |
> 15 | axios(config).then((res: AxiosResponse<RepositoryModel[]>) => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 | console.log(res.data);
17 | });
```
#### Expected behavior
This issue was resolved in `0.24` however the type can still not be explicitly set like in this example:
```typescript
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
const config: AxiosRequestConfig = {
method: 'get',
url: 'https://api.github.com/users/jelleschutter/repos?per_page=1'
}
type RepositoryModel = {
full_name: string;
description: string;
}
axios<RepositoryModel[]>(config).then(res => {
console.log(res.data);
});
```
#### Environment
- Axios Version: 0.23.0
- Node.js Version: 14.15.4
- OS: Windows 10
#### Additional context/Screenshots
\-
|
https://github.com/axios/axios/issues/4223
|
https://github.com/axios/axios/pull/4224
|
d60d6844b15204a87c96ad289cb502a9647ed6cc
|
ed0ba0fd60e43cdf80b18aee767a9946acda6705
| 2021-10-27T14:21:17Z |
javascript
| 2022-05-16T07:08:02Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,157 |
["Gruntfile.js", "index.d.ts", "package.json", "test/typescript/axios.ts", "tsconfig.json", "tslint.json"]
|
Version 0.22.0 breaks TypeScript apps
|
#### Describe the bug
Upgrading from version 0.21.4 to 0.22.0 fails to compile a TypeScript app.
#### To Reproduce
Have a code that looks like this
```ts
import axios from 'axios';
const func = () => {
delete axios.defaults.headers.common.Authorization;
}
```
Request responses are also incorrectly inferred after this update. Instead of `any`, data will be set to `Params`.
```ts
import axios from 'axios';
export const request = async (params: Params): Promise<Response> => {
const { data } = await axios.put('urlPath', params);
return data;
};
```
#### Expected behavior
There should be no breaking changes as change log doesn't mention them.
#### Environment
- Axios Version [e.g. 0.18.0] 0.22.0
- Adapter [e.g. XHR/HTTP] -
- Browser [e.g. Chrome, Safari] -
- Browser Version [e.g. 22] -
- Node.js Version [e.g. 13.0.1] -
- OS: [e.g. iOS 12.1.0, OSX 10.13.4] -
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0] React 17.0.2
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/4157
|
https://github.com/axios/axios/pull/4140
|
fce210a67e240820cc2c9b146ac80ba6985b8477
|
94a93447992392441f1928dffc9f10529ecec417
| 2021-10-07T11:30:43Z |
javascript
| 2021-10-12T07:53:10Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,153 |
["Gruntfile.js", "index.d.ts", "package.json", "test/typescript/axios.ts", "tsconfig.json", "tslint.json"]
|
Uncaught TypeError is raised for axios.create with axios version 0.22.0
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
Uncaught TypeError is raised for axios.create with axios version 0.22.0
Issue is observed while merging the defaultConfig, with instanceConfig.
We are setting instanceConfig only
#### To Reproduce
Exception is raised while creating axios instance with below sample code.
```js
const service = axios.create({
baseURL: "host",
timeout: 3000
})
```
#### Expected behavior
Same works with axios version 0.21.4
#### Environment
- Axios Version [0.22.0]
- Browser [Chrome, Edge]
- Browser Version [Version 94.0.4606.71 (Official Build) (64-bit)]
- Node.js Version [14.15.1]
- Additional Library Versions [VueJS 3.2.19, vue-axios 3.3.7]
#### Additional context/Screenshots
Exception stack trace
axios.js:1308 Uncaught TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at mergeConfig (axios.js:1308)
at Function.create (axios.js:1712)
|
https://github.com/axios/axios/issues/4153
|
https://github.com/axios/axios/pull/4140
|
fce210a67e240820cc2c9b146ac80ba6985b8477
|
94a93447992392441f1928dffc9f10529ecec417
| 2021-10-07T08:41:44Z |
javascript
| 2021-10-12T07:53:10Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,141 |
["index.d.ts", "test/typescript/axios.ts"]
|
Revert #3002 - set type of data to any
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Is your feature request related to a problem? Please describe.
Yes. After #3002 was merged, we are now required to set explicit type definitions for every single axios request we make, even if we don't want to, because these would result in an error.
#### Describe the solution you'd like
The default type for AxiosResponse#data should be any so that we can modify it if we want, or keep it as is if we don't care about the typings for that specific request
#### Describe alternatives you've considered
As suggested in that PR, we could set the type to `any` explicitly, however, many people use typescript-eslint's [no-explicit-any](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-explicit-any.md) rule that prevents us from doing this. I believe everyone should be able to choose what types they wanna work with, because for extremely simple responses from which you only need one or two simple properties you don't always need explicit type declarations
#### Additional context
TypeScript's DOM library sets the return type of Body#toJSON to Promise<any>, so we should be following the native approach and not restricting user's options by setting a default that "most users may want", even if most users do not want this.
|
https://github.com/axios/axios/issues/4141
|
https://github.com/axios/axios/pull/4186
|
1025d1231a7747503188459dd5a6d1effdcea928
|
2c9cc76ee9cce0a144a68d5a6b2b8f4da89c6e15
| 2021-10-05T14:00:06Z |
javascript
| 2021-10-22T08:14:23Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,132 |
["Gruntfile.js", "index.d.ts", "package.json", "test/typescript/axios.ts", "tsconfig.json", "tslint.json"]
|
POST call expected response body type also set to request body type
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
When specifying an expected `response.data` type to the post method it also sets that expected type to the request body. Also, when not specifying a type, the type for the `response.data` gets inferred to be the same as the type of the request body. This leads to typescript errors in VS Code and during compile time when the response and request bodies in code doesn't have the same type (which is usually the case). This was not an issue in v0.21.4 - which I reverted to in order to get around this issue.
#### To Reproduce
1. Install axios v0.22.0
2. Add a type for the `response.data` like in this example:
```tsx
axios.post<ExpectedResponseBody>(`post url`, { foo: "bar" }, {});
```
Also look at the CodeSandbox example [here](https://codesandbox.io/s/axios-v0-22-0-type-issue-joty3?file=/src/App.tsx:897-1031)
#### Expected behavior
When specifying the expected type of the `response.data` in the post call, the request body shouldn't have the same expected type. And the inferred type for the request body shouldn't automatically get applied to `response.data`.
#### Environment
- Axios Version 0.22.0
- Adapter N/A
- Browser N/A
- Browser Version N/A
- Node.js Version: 14.17.3
- OS: Win 10
- Additional Library Versions: Typescript 4.4.3
#### Additional context/Screenshots
Type for post method in axios v0.21.4

Type for post method in axios v0.22.0. Note that `T` is also set to request data and config in this version - which is what I believe is the cause of the issue.

|
https://github.com/axios/axios/issues/4132
|
https://github.com/axios/axios/pull/4140
|
fce210a67e240820cc2c9b146ac80ba6985b8477
|
94a93447992392441f1928dffc9f10529ecec417
| 2021-10-04T09:16:49Z |
javascript
| 2021-10-12T07:53:10Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,124 |
["index.d.ts", "test/typescript/axios.ts"]
|
Usage of AbortController ist breaking for setup without DOM Library
|
#### Describe the bug
Axios has been using the `AbortController` from the DOM library since version 0.22.0 (# 3305). Since then, the DOM library has to be stored in tsconfig.json. Without DOM the new version is breaking for our setup and can no longer be used.
#### To Reproduce
Use `axios.get()` without DOM Library. To reproduce change `tsconfig.json` to eg.:
```
...
"lib": ["ES2020"],
...
```
#### Expected behavior
axios should work without DOM. Maybe there is an alternative for `AbortController`?
#### Environment
- Axios Version 0.22.0
- Adapter http
- Browser none
- Node.js Version 14.18.0
- OS: macOS 11.6
#### Additional context/Screenshots
Given Exception:
```
> @smirowstanitzok/[email protected] build /home/runner/work/trendytag-sdk/trendytag-sdk
> tsc
Error: node_modules/axios/index.d.ts(81,12): error TS2304: Cannot find name 'AbortSignal'.
Error: src/index.ts(189,13): error TS2322: Type 'unknown' is not assignable to type 'AxiosResponse<ContactFormResponse> | undefined'.
Type 'unknown' is not assignable to type 'AxiosResponse<ContactFormResponse>'.
Error: src/index.ts(189,88): error TS2345: Argument of type 'ContactForm' is not assignable to parameter of type 'ContactFormResponse'.
Property 'messageId' is missing in type 'ContactForm' but required in type 'ContactFormResponse'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @smirowstanitzok/[email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @smirowstanitzok/[email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-10-01T08_27_20_612Z-debug.log
Error: Process completed with exit code 2.
```
|
https://github.com/axios/axios/issues/4124
|
https://github.com/axios/axios/pull/4229
|
eaaab30442e6d4206d03c7fe0961b37e7ca51424
|
384b7e6994c7392e4a39056ee5bb56755bcac11a
| 2021-10-02T11:27:51Z |
javascript
| 2022-05-04T19:23:01Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 4,108 |
["Gruntfile.js", "index.d.ts", "package.json", "test/typescript/axios.ts", "tsconfig.json", "tslint.json"]
|
defaults.headers.common is of type string instead of Record<string, string>
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the issue
Headers are typed as `Record<string, string>`. This includes `axios.defaults.headers`, which is configured as: https://github.com/axios/axios/blob/76f09afc03fbcf392d31ce88448246bcd4f91f8c/lib/defaults.js#L119-L123
This seems incompatible with `headers` being of type `Record<string, string>`.
#### Example Code
The following line produces a TypeScript error beacuse `headers.commons` is of type `string`: "Element implicitly has an 'any' type because index expression is not of type 'number'.ts(7015)".
```ts
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN
```
#### Expected behavior, if applicable
I expect to be able to configure default headers without TypeScript errors. Using the code examples from the Axios documentation, I would exspect `axios.defaults.headers.common` to be of type `Record<string, string>` not of type `string`.
#### Environment
- Axios Version 0.22.0
- Adapter N/A
- Browser N/A
- Browser Version N/A
- Node.js Version 15.14.0
- OS: Ubuntu 21.04
- Additional Library Versions TypeScript 4.4.3
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/4108
|
https://github.com/axios/axios/pull/4140
|
fce210a67e240820cc2c9b146ac80ba6985b8477
|
94a93447992392441f1928dffc9f10529ecec417
| 2021-10-01T08:39:14Z |
javascript
| 2021-10-12T07:53:10Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,979 |
["lib/utils.js"]
|
[Security] Regular expression Denial of Service (ReDoS)
|
#### Describe the bug
A ReDoS (regular expression denial of service) flaw was found in the axios package. An attacker that is able to provide crafted input to the trim function may cause an application to consume an excessive amount of CPU.
https://www.huntr.dev/bounties/1e8f07fc-c384-4ff9-8498-0690de2e8c31/
#### To Reproduce
Code snippet to reproduce, ideally, that will work by pasting into something like https://npm.runkit.com/axios
```js
var {trim} = require("axios/lib/utils");
function build_blank (n) {
var ret = "1"
for (var i = 0; i < n; i++) {
ret += " "
}
return ret + "1";
}
var time = Date.now();
trim(build_blank(50000))
var time_cost = Date.now() - time;
console.log("time_cost: " + time_cost)
```
#### Expected behavior
#### Environment
- Axios Version [e.g. 0.21.1]
- Adapter [e.g. XHR/HTTP]
- Browser [e.g. Chrome, Safari]
- Browser Version [e.g. 22]
- Node.js Version [e.g. 14.17.5]
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/3979
|
https://github.com/axios/axios/pull/3980
|
5bc9ea24dda14e74def0b8ae9cdb3fa1a0c77773
|
5b457116e31db0e88fede6c428e969e87f290929
| 2021-08-26T14:17:32Z |
javascript
| 2021-08-30T12:33:43Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,941 |
["lib/adapters/http.js"]
|
uncaughtException from steam's end callback
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
`axios.get(url)` is never returning the response when the following error occurs. It should have rejected the promise internally so that caller will get an exception. This issue is raised all the way to the process.on("uncaughtException"... I checked the http.js file line 251. I think if node throws an error here the settle will never be called. Do we need try-catch for the stream.end callback?
RangeError: Array buffer allocation failed
at new ArrayBuffer ()
at new Uint8Array ()
at new FastBuffer (internal/buffer.js:956:5)
at createUnsafeBuffer (buffer.js:152:12)
at allocate (buffer.js:419:10)
at Function.allocUnsafe (buffer.js:384:10)
at Function.concat (buffer.js:564:25)
at IncomingMessage.handleStreamEnd (/home/posintg/verifone-21.06.30/node_modules/axios/lib/adapters/http.js:251:37)
at IncomingMessage.emit (events.js:387:35)
at endReadableNT (internal/streams/readable.js:1317:12)
#### To Reproduce
It is hard to reproduce. You would have to cause exception at line below
```js
stream.on('end', function handleStreamEnd() {
var responseData = Buffer.concat(responseBuffer); //error is thrown here
if (config.responseType !== 'arraybuffer') {
responseData = responseData.toString(config.responseEncoding);
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
responseData = utils.stripBOM(responseData);
}
}
response.data = responseData;
settle(resolve, reject, response);
});
// Example code here
const response = await axios.get(url);
```
```js
// Example code here
const response = await axios.get(url);
```
#### Expected behavior
Should reject the promise and so caller would be able to handle it.
#### Environment
- Axios Version 0.21.1
- Adapter HTTP
- Browser n/a
- Browser Version n/a
- Node.js Version 14.17.2
- OS: Debian 10
- Additional Library Versions: n/a
#### Additional context/Screenshots
none
|
https://github.com/axios/axios/issues/3941
|
https://github.com/axios/axios/pull/3967
|
4fbf61dc751ad69c7df9977d6edf7cf7ee87a5fb
|
ea0d9c69f78070dae841c66efd7263e246cab845
| 2021-08-08T13:58:34Z |
javascript
| 2021-12-23T17:28:10Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,903 |
["lib/adapters/http.js", "package.json", "test/unit/adapters/http.js"]
|
Requests to https through proxy
|
#### Is your feature request related to a problem? Please describe.
Axios 0.21.1 does not cope with requests through proxy to secured URLs - HTTP code 501 is received.
I'm behind corporate network. When I try to launch the following code, the error 501 is received:
```
const axios = require("axios");
axios.get('https://jsonplaceholder.typicode.com/todos/12', {
proxy: {
protocol: 'http',
host: 'corporate.proxy',
port: 9000
},
})
.then(response => response.data)
.then(data => console.log(data))
.catch((error) => {
const errorMessage = error.message;
const responseData = error.response && error.response.data;
console.log('error')
console.log(`${errorMessage}${
responseData
&& typeof responseData === 'object'
? `: ${JSON.stringify(responseData)}`
: ''}`)
});
```
Requests made to unsecured URLs - http protocol - with or without proxy settings succeed.
#### Describe the solution you'd like
Fix or implement please a possibility to perform requests to secured URLs - https protocol - through proxy.
#### Describe alternatives you've considered
Instead of using "axios" module, the module "axios-https-proxy-fix" solves the issue. However, it's some old fix. And most probably does not update to new features that original Axios may bring. Definitely I would like to stick to primary.
#### Additional context
No solution is found around the original source.
|
https://github.com/axios/axios/issues/3903
|
https://github.com/axios/axios/pull/4436
|
de5e006142cb428e712d00c05bda17c3c4c83ef1
|
495d5fb1333f2cb0c7e49ecfd6470dd1700ca96c
| 2021-07-20T07:11:36Z |
javascript
| 2022-05-11T17:24:14Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,887 |
["lib/adapters/http.js", "lib/helpers/ZlibHeaderTransformStream.js", "test/unit/adapters/http.js"]
|
Deflate fails on server response without zlib header
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
Some servers are not sending a zlib header in their deflated data. CURL had the same problem and implemented a "fix" for it: https://github.com/curl/curl/blob/5c932f8fe9dad94a7417702958ffa9e8db67c549/lib/content_encoding.c#L227-L229
Axios is also returning a `Z_DATA_ERROR` in this case.
#### To Reproduce
Use axios to request a page without a zlib header in the deflated data (e.g. https://www.konicaminolta.eu/eu-en/about-us/corporate-book) and force it to only accept deflate encoding.
```js
let url = 'https://www.konicaminolta.eu/eu-en/about-us/corporate-book';
let config = {
headers: { 'Accept-Encoding': 'deflate' }
};
await axios.get(url, config);
```
#### Expected behavior
Getting the correctly inflated data.
#### Environment
- Axios Version [0.21.1]
#### Additional context/Screenshots
|
https://github.com/axios/axios/issues/3887
|
https://github.com/axios/axios/pull/5497
|
9915635c69d0ab70daca5738488421f67ca60959
|
65e8d1e28ce829f47a837e45129730e541950d3c
| 2021-07-07T06:49:51Z |
javascript
| 2023-01-30T22:49:37Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,798 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
http adapter stream never ends and request hangs
|
#### Describe the bug
Intermittent hangs with requests that I've debugged down to end not being called on the stream.
#### To Reproduce
Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue. **If your problem is not reproducible, please file under Support or Usage Question**
Excerpts from my code showing the Axios call
```js
const SocksProxyAgent = require('socks-proxy-agent')
const proxyOptions = `socks5://127.0.0.1:9050`
const httpsAgent = new SocksProxyAgent(proxyOptions)
const client = axios.create({ httpsAgent })
...
try {
response = await client.get(url) <---- the call of no return
} catch (err) {
outcodeLogger.error(err) <---- it never gets here
throw new Error(`HTTP error ${err} for outcode ${outcodeNumber} `)
} finally {
outcodeLogger.trace('13') <---- it never gets here
}
<---- it never gets here
```
Axios http.js with debug messages added
```js
'use strict';
var utils = require('./../utils');
var settle = require('./../core/settle');
var buildFullPath = require('../core/buildFullPath');
var buildURL = require('./../helpers/buildURL');
var http = require('http');
var https = require('https');
var httpFollow = require('follow-redirects').http;
var httpsFollow = require('follow-redirects').https;
var url = require('url');
var zlib = require('zlib');
var pkg = require('./../../package.json');
var createError = require('../core/createError');
var enhanceError = require('../core/enhanceError');
var isHttps = /https:?/;
/**
*
* @param {http.ClientRequestArgs} options
* @param {AxiosProxyConfig} proxy
* @param {string} location
*/
function setProxy(options, proxy, location) {
options.hostname = proxy.host;
options.host = proxy.host;
options.port = proxy.port;
options.path = location;
// Basic proxy authorization
if (proxy.auth) {
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
}
// If a proxy is used, any redirects must also pass through the proxy
options.beforeRedirect = function beforeRedirect(redirection) {
redirection.headers.host = redirection.host;
setProxy(redirection, proxy, redirection.href);
};
}
/*eslint consistent-return:0*/
module.exports = function httpAdapter(config) {
const {url:u}=config
console.log(`${u} start httpAdapter`)
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
var resolve = function resolve(value) {
resolvePromise(value);
};
var reject = function reject(value) {
rejectPromise(value);
};
var data = config.data;
var headers = config.headers;
// Set User-Agent (required by some servers)
// Only set header if it hasn't been set in config
// See https://github.com/axios/axios/issues/69
if (!headers['User-Agent'] && !headers['user-agent']) {
headers['User-Agent'] = 'axios/' + pkg.version;
}
console.log(`${u} buffer stuff`)
if (data && !utils.isStream(data)) {
if (Buffer.isBuffer(data)) {
// Nothing to do...
} else if (utils.isArrayBuffer(data)) {
data = Buffer.from(new Uint8Array(data));
} else if (utils.isString(data)) {
data = Buffer.from(data, 'utf-8');
} else {
return reject(createError(
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
config
));
}
// Add Content-Length header if data exists
headers['Content-Length'] = data.length;
}
// HTTP basic authentication
console.log(`${u} start auth`)
var auth = undefined;
if (config.auth) {
var username = config.auth.username || '';
var password = config.auth.password || '';
auth = username + ':' + password;
}
// Parse url
console.log(`${u} start parse url`)
var fullPath = buildFullPath(config.baseURL, config.url);
var parsed = url.parse(fullPath);
var protocol = parsed.protocol || 'http:';
if (!auth && parsed.auth) {
var urlAuth = parsed.auth.split(':');
var urlUsername = urlAuth[0] || '';
var urlPassword = urlAuth[1] || '';
auth = urlUsername + ':' + urlPassword;
}
if (auth) {
delete headers.Authorization;
}
var isHttpsRequest = isHttps.test(protocol);
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
console.log(`${u} build url`)
var options = {
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
method: config.method.toUpperCase(),
headers: headers,
agent: agent,
agents: { http: config.httpAgent, https: config.httpsAgent },
auth: auth
};
if (config.socketPath) {
options.socketPath = config.socketPath;
} else {
options.hostname = parsed.hostname;
options.port = parsed.port;
}
console.log(`${u} start proxy`)
var proxy = config.proxy;
if (!proxy && proxy !== false) {
var proxyEnv = protocol.slice(0, -1) + '_proxy';
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
if (proxyUrl) {
var parsedProxyUrl = url.parse(proxyUrl);
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
var shouldProxy = true;
if (noProxyEnv) {
var noProxy = noProxyEnv.split(',').map(function trim(s) {
return s.trim();
});
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
if (!proxyElement) {
return false;
}
if (proxyElement === '*') {
return true;
}
if (proxyElement[0] === '.' &&
parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
return true;
}
return parsed.hostname === proxyElement;
});
}
if (shouldProxy) {
proxy = {
host: parsedProxyUrl.hostname,
port: parsedProxyUrl.port,
protocol: parsedProxyUrl.protocol
};
if (parsedProxyUrl.auth) {
var proxyUrlAuth = parsedProxyUrl.auth.split(':');
proxy.auth = {
username: proxyUrlAuth[0],
password: proxyUrlAuth[1]
};
}
}
}
}
console.log(`${u} start proxy 2`)
if (proxy) {
options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
}
console.log(`${u} start transport`)
var transport;
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
if (config.transport) {
transport = config.transport;
} else if (config.maxRedirects === 0) {
transport = isHttpsProxy ? https : http;
} else {
if (config.maxRedirects) {
options.maxRedirects = config.maxRedirects;
}
transport = isHttpsProxy ? httpsFollow : httpFollow;
}
if (config.maxBodyLength > -1) {
options.maxBodyLength = config.maxBodyLength;
}
console.log(`${u} start create request`)
// Create the request
var req = transport.request(options, function handleResponse(res) {
if (req.aborted) return;
// uncompress the response body transparently if required
var stream = res;
// return the last request in case of redirects
var lastRequest = res.req || req;
// if no content, is HEAD request or decompress disabled we should not decompress
if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
switch (res.headers['content-encoding']) {
/*eslint default-case:0*/
case 'gzip':
case 'compress':
case 'deflate':
// add the unzipper to the body stream processing pipeline
stream = stream.pipe(zlib.createUnzip());
// remove the content-encoding in order to not confuse downstream operations
delete res.headers['content-encoding'];
break;
}
}
var response = {
status: res.statusCode,
statusText: res.statusMessage,
headers: res.headers,
config: config,
request: lastRequest
};
if (config.responseType === 'stream') {
response.data = stream;
settle(resolve, reject, response);
} else {
var responseBuffer = [];
stream.on('data', function handleStreamData(chunk) {
console.log(`${u} stream.on start`)
responseBuffer.push(chunk);
console.log(`${u} stream.on pushed ${config.maxContentLength} ${Buffer.concat(responseBuffer).length}`)
// make sure the content length is not over the maxContentLength if specified
if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
stream.destroy();
console.log(`${u} destroy`)
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
config, null, lastRequest));
console.log(`${u} rejected`)
}
console.log(`${u} end`)
});
stream.on('error', function handleStreamError(err) {
console.log(`${u} stream.on error`)
if (req.aborted) return;
reject(enhanceError(err, config, null, lastRequest));
});
stream.on('end', function handleStreamEnd() {
console.log(`${u} stream.on end`)
var responseData = Buffer.concat(responseBuffer);
if (config.responseType !== 'arraybuffer') {
responseData = responseData.toString(config.responseEncoding);
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
responseData = utils.stripBOM(responseData);
}
}
response.data = responseData;
settle(resolve, reject, response);
});
}
});
console.log(`${u} start handle errors`)
// Handle errors
req.on('error', function handleRequestError(err) {
console.log(`${u} ${err.code}`)
console.log(`${u} ${req.aborted}`)
if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
reject(enhanceError(err, config, null, req));
});
console.log(`${u} start timeout to ${config.timeout}`)
// Handle request timeout
if (config.timeout) {
// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
// And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
// And then these socket which be hang up will devoring CPU little by little.
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
req.setTimeout(config.timeout, function handleRequestTimeout() {
console.log(`${u} timeout1`)
req.abort();
console.log(`${u} timeout2`)
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
console.log(`${u} timeout3`)
});
}
console.log(`${u} timeout4`)
if (config.cancelToken) {
console.log(`${u} timeout5`)
// Handle cancellation
config.cancelToken.promise.then(function onCanceled(cancel) {
if (req.aborted) return;
req.abort();
reject(cancel);
});
}
console.log(`${u} timeout6`)
// Send the request
if (utils.isStream(data)) {
data.on('error', function handleStreamError(err) {
console.log(`${u} data.on error`)
reject(enhanceError(err, config, null, req));
}).pipe(req);
} else {
console.log(`${u} 888`)
req.end(data);
}
console.log(`${u} 999`)
});
};
```
```
<URL> start proxy
<URL> start proxy 2
<URL> start transport
<URL> start create request
<URL> start handle errors
<URL> start timeout to 0
<URL> timeout4
<URL> timeout6
<URL> 888
<URL> 999
<URL> stream.on start
<URL> stream.on pushed -1 812
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 2260
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 3708
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 5156
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 6604
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 8052
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 8184
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 9492
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 10940
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 12388
<URL> end
<URL> stream.on start
<URL> stream.on pushed -1 13836
<URL> end
No call to stream.end so the promise is never resolved/rejected
```
#### Expected behavior
It doesn't hang or it times out
#### Environment
- Axios Version 0.21.1
- Adapter HTTP
- Browser n/a
- Browser Version n/a
- Node.js Version 14.16
- OS: Ubuntu 20.04
- Additional Library Versions : using socks-proxy-agent": "^5.0.0",
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/3798
|
https://github.com/axios/axios/pull/3916
|
1885ac79c535d5c932b09aaa40dd96223972d138
|
c5fe05bdff82e0fa4ace9a832e75052e1ee297f0
| 2021-05-15T09:05:39Z |
javascript
| 2021-10-29T08:05:01Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,769 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
maxBodyLength does not work with disabled redirects
|
#### Describe the bug
maxBodyLength does not work with disabled redirects like when using `{ maxRedirects: 0, maxBodyLength: 100 }` in options.
#### To Reproduce
```js
require("axios")
.put("http://www.example.com", Buffer.alloc(1000), { maxRedirects: 0, maxBodyLength: 100 })
.catch(e => console.log("axios returned error:", e));
```
#### Expected behavior
It should print something like:
```
axios returned error: Error [ERR_FR_MAX_BODY_LENGTH_EXCEEDED]: Request body larger than maxBodyLength limit
...
```
As this example does:
```js
require("axios")
.put("http://www.example.com", Buffer.alloc(1000), { maxBodyLength: 100 })
.catch(e => console.log("axios returned error:", e));
```
#### Environment
- Axios Version 0.21.1
- Adapter HTTP
- Node.js Version v15.12.0
#### Additional context/Screenshots
|
https://github.com/axios/axios/issues/3769
|
https://github.com/axios/axios/pull/3786
|
962f9ab7129f38024f73a75e2869feaa6eb2d260
|
c00c4ddd87fc616e85b64ed4cfad19eec44f49a6
| 2021-04-28T18:15:35Z |
javascript
| 2021-12-23T08:19:02Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,751 |
["package-lock.json"]
|
React+axios: global catch interceptor still requires me to add a catch clause per request
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the issue
When setting a global catch interceptor, I still need to define a catch clause, otherwise I get an error page of un handled rejection. If I don't throw an error from the interceptor, the "then" clause is executing which is wrong.
#### Example Code
```
apiClient.interceptors.response.use(response => response, error => {
//do some stuff
throw error; //<<<<< see below for details
})
apiClient.post("/login", {.....}).then((response) => {
alert(response);
}).catch(ignored => {
});
```
#### Expected behavior, if applicable
If a global interceptor is defined, either I won't be forced to add a catch clause per request or when not throwing an error, the "then" clause should't be executed.
#### Environment
- Axios Version 0.21.1
- Adapter HTTP
- Browser Firefox
- Browser Version 87
- OS: Windows 10
- Additional Library Versions: React 17.0.2
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/3751
|
https://github.com/axios/axios/pull/4461
|
73e3bdb8835ba942096b662e9441f1d85ce4d484
|
447a24dfc337f93d35b9a8bed7629a76f7aed6bf
| 2021-04-15T23:37:00Z |
javascript
| 2022-02-13T13:45:14Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,733 |
["index.d.ts"]
|
InterceptorManager.use type does not include the third parameter `options`
|
#### Describe the bug
The [type declared for InterceptorManager.use](https://github.com/axios/axios/blob/master/index.d.ts#L126) does not include the third parameter (`options`), so typescript projects show an error when supplying it.
#### To Reproduce
Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue. **If your problem is not reproducible, please file under Support or Usage Question**
```ts
axios.interceptors.request.use(config => config, null, { synchronous: true });
// ^ red squiggle here
```

#### Expected behavior
The type includes the optional third parameter, an object with a boolean `synchronous` property, and a `runWhen` property that takes an `AxiosRequestConfig` and returns a boolean;
#### Environment
- Axios Version [e.g. 0.18.0]
- Adapter [e.g. XHR/HTTP]
- Browser [e.g. Chrome, Safari]
- Browser Version [e.g. 22]
- Node.js Version [e.g. 13.0.1]
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/3733
|
https://github.com/axios/axios/pull/3800
|
bdb7d76d40407443dceaf9efa5d5a01ee4ef4da5
|
224ed940e15b615336bc104b3478b137f7a48b86
| 2021-04-07T14:33:08Z |
javascript
| 2022-03-07T18:26:50Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,732 |
["README.md"]
|
add isAxiosError to docs
|
#### Section/Content To Improve
add `isAxiosError` to docs
#### Suggested Improvement
`isAxiosError` flag and type-guard-aware function already added to the Axios (axios/axios#1415) but there is no explanation for it in the docs
#### Relevant File(s)
README.md
|
https://github.com/axios/axios/issues/3732
|
https://github.com/axios/axios/pull/3767
|
0ece97c7a949eca32af6aed1e4be08f01ad20e9f
|
94fc4ea7161b1e13c55df102e3177b53d26ef00e
| 2021-04-07T09:00:46Z |
javascript
| 2021-05-04T18:05:05Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,702 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
Can't completely remove User-Agent Header
|
#### Is your feature request related to a problem? Please describe.
Some APIs only work if the User-Agent header is entirely omitted. This is not currently possible in Axios in NodeJS. #1411 opened this discussion some time back, but was closed without an actual solution other than commenting out the code which inserts the header.
#### Describe the solution you'd like
There should be a way to completely omit the U-A header if desired. User-Agent is not a required header, and its deprecation (in favor of Client-Hints) is being actively discussed.
The simplest solution would probably to retain the current behavior if no User-Agent header is specified, but omit the header if it is explicitly provided with a falsy value (`null` and `""` both seem to clearly communicate the caller's intent not to have a value here).
#### Describe alternatives you've considered
Explicit options to disable the current behavior could work, but that seems like a less-elegant path.
#### Additional context
No.
|
https://github.com/axios/axios/issues/3702
|
https://github.com/axios/axios/pull/3703
|
c0317b745306ba312437a04803b8d3ea46390181
|
b0959f0301d3c1bb5ca673c20a58907e94e3743d
| 2021-03-23T20:09:14Z |
javascript
| 2021-03-29T14:47:29Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,680 |
["package.json"]
|
Change the "homepage" field in package.json to point to axios' new website
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Is your feature request related to a problem? Please describe.
No.
#### Describe the solution you'd like
I've created a pull request that takes care of this
#### Describe alternatives you've considered
โ
#### Additional context
Since axios now has a website, axios-http.com, I think it is best if the "Homepage" link on the npm page points to that site.
|
https://github.com/axios/axios/issues/3680
|
https://github.com/axios/axios/pull/3681
|
62d625603916115691bcea2842c5d6e331279b99
|
5c122b7eaf279ce2b9de2894283aacd062192f17
| 2021-03-15T15:10:14Z |
javascript
| 2021-03-15T15:17:33Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,606 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
response interceptor should have request infomation on error
|
#### Describe the bug
This bugreport very similar to #315 which was implemented and fixed, however I think this is not solved yet. When the query params parsing process itself fails (before the request even started), the resulting error object does not contain request information, making it hard to debug, especially with as error reports.
#### To Reproduce
```js
axios.get("", {
params: {
someParam: new Date(undefined)
}
}).catch((e) => {
console.log(e);
})
```
Only prints
```
RangeError: Invalid time value
at Date.toISOString (<anonymous>)
at parseValue (buildURL.js:53)
at Object.forEach (utils.js:219)
at serialize (buildURL.js:51)
at Object.forEach (utils.js:225)
at buildURL (buildURL.js:38)
at dispatchXhrRequest (xhr.js:45)
at new Promise (<anonymous>)
at xhrAdapter (xhr.js:13)
at dispatchRequest (dispatchRequest.js:53)
```
#### Expected behavior
I would expect the error to have information about the request (uri, config, etc) just like when the error is thrown on server response error.
#### Environment
- Axios Version 0.21.1
- Adapter http
- Browser chromium
- Browser Version 87.0.4280.141
- Node.js Version 12.20.0
- OS: Manjaro 20.2.1
- Additional Library Versions none
#### Additional context/Screenshots
dont have any. โ I dont think that omitting this category should result in the automatic closing of an issue :-/
Cheers
|
https://github.com/axios/axios/issues/3606
|
https://github.com/axios/axios/pull/3961
|
4461761fcb75a63fe4eab217e9e9632f48aa4dee
|
1163588aa288160282866057efcaef57dbbe417b
| 2021-01-28T19:59:28Z |
javascript
| 2022-01-18T16:50:33Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,580 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
The timeoutErrorMessage property in config not work with Node.js
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
The timeoutErrorMessage property in config not work with Node.js, expected custom error message, got "**timeout of \*ms exceeded**"
#### To Reproduce
```js
it('should respect the timeoutErrorMessage property', function (done) {
server = http.createServer(function (req, res) {
setTimeout(function () {
res.end();
}, 1000);
}).listen(4444, function () {
var success = false, failure = false;
var error;
axios.get('http://localhost:4444/', {
timeout: 250,
timeoutErrorMessage: 'oops, timeout',
}).then(function (res) {
success = true;
}).catch(function (err) {
error = err;
failure = true;
});
setTimeout(function () {
assert.strictEqual(success, false, 'request should not succeed');
assert.strictEqual(failure, true, 'request should fail');
assert.strictEqual(error.code, 'ECONNABORTED');
assert.strictEqual(error.message, 'oops, timeout');
done();
}, 300);
});
});
```
#### Expected behavior
Expected: oops, timeout
Got: timeout of 250ms exceeded
#### Environment
- Axios Version: 0.21.1
- Adapter: HTTP
- Browser: none
- Browser Version: none
- Node.js Version: 12.19.0
- OS: MacOS 10.14
- Additional Library Versions: none
#### Additional context/Screenshots

|
https://github.com/axios/axios/issues/3580
|
https://github.com/axios/axios/pull/3581
|
5c5cbdf4ba1e2b55b6bff35673bdd5206b4eddf8
|
4461761fcb75a63fe4eab217e9e9632f48aa4dee
| 2021-01-22T17:10:24Z |
javascript
| 2022-01-18T16:40:18Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,550 |
["CHANGELOG.md", "bower.json", "dist/axios.js", "dist/axios.map", "dist/axios.min.js", "dist/axios.min.map", "package.json"]
|
0.21.1 missing from CHANGELOG
|
<!-- Click "Preview" for a more readable version --
If you found an area that needs clarification, feel free to open a PR or list the section/content that could be improved below
Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to refer to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Section/Content To Improve
https://github.com/axios/axios/blob/master/CHANGELOG.md
#### Suggested Improvement
Please add 0.21.1 to the Changelog.
#### Relevant File(s)
https://github.com/axios/axios/blob/master/CHANGELOG.md
|
https://github.com/axios/axios/issues/3550
|
https://github.com/axios/axios/pull/3610
|
9a4d7ac236eb101a290f2809c20538fd87677ec9
|
7d3b626a595e5b911c59dfb28a8080e56d840602
| 2021-01-14T21:41:22Z |
javascript
| 2021-01-31T18:17:04Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,509 |
["lib/adapters/http.js", "lib/adapters/xhr.js", "lib/utils.js", "test/specs/requests.spec.js", "test/unit/adapters/http.js"]
|
The irrelevant error returned when requesting illegal URL
|
#### Describe the bug
The irrelevant error returned when requesting illegal URL, like: "tel:484-695-3408"
```
TypeError: Cannot read property 'replace' of null
at dispatchHttpRequest (node_modules/axios/lib/adapters/http.js:109:74)
at new Promise (<anonymous>)
at httpAdapter (node_modules/axios/lib/adapters/http.js:46:10)
at dispatchRequest (node_modules/axios/lib/core/dispatchRequest.js:52:10)
```
#### To Reproduce
```js
axios.get('tel:484-695-3408').catch(err => console.error(err));
```
#### Expected behavior
Return descriptive error, like "Unsupported protocol tel:"
#### Environment
- Axios Version: 0.21.1
- Adapter: HTTP
- Browser: none
- Browser Version: none
- Node.js Version: 12.19.0
- OS: MacOS 10.14
- Additional Library Versions: none
#### Additional context/Screenshots
none
|
https://github.com/axios/axios/issues/3509
|
https://github.com/axios/axios/pull/3544
|
412d3bd6078433dda4a7eb4d86e021dbc57fdeb2
|
195c8e5ff5af6506e5c3e9423cd3c6e839b9cc86
| 2020-12-30T08:56:11Z |
javascript
| 2022-03-07T17:53:57Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,448 |
["index.d.ts"]
|
Support developers to customize return types in the interceptors.
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Is your feature request related to a problem? Please describe.
I was using `interceptors` like
```js
axios.interceptors.response.use(function (
response: AxiosResponse<YApiResponseBody>
): YApiResponseBody {
return response.data
},
```
However, I got the error
> Argument of type '(response: AxiosResponse<YApiResponseBody>) => YApiResponseBody' is not assignable to parameter of type '(value: AxiosResponse<any>) => AxiosResponse<any> | Promise<AxiosResponse<any>>'.
Yeah, I know the error means, however, I just want to return the `response.data` directly. How can I accomplish that?
#### Describe the solution you'd like
#### Describe alternatives you've considered
I was thinking if `AxiosInterceptorManager` can accept `any` in `onFulfilled`. In that case, the error won't appear again.
```diff
export interface AxiosInterceptorManager<V> {
- use(onFulfilled?: (value: V) =>V | Promise<V>, onRejected?: (error: any) => any): number;
+ use(onFulfilled?: (value: V) =>any , onRejected?: (error: any) => any): number;
eject(id: number): void;
}
export interface AxiosInstance {
(config: AxiosRequestConfig): AxiosPromise;
(url: string, config?: AxiosRequestConfig): AxiosPromise;
defaults: AxiosRequestConfig;
interceptors: {
request: AxiosInterceptorManager<AxiosRequestConfig>;
response: AxiosInterceptorManager<AxiosResponse>;
};
//...
}
```
I have seen https://github.com/axios/axios/issues/1510 and https://github.com/axios/axios/pull/1605. I didn't find a solution.
#### Additional context
|
https://github.com/axios/axios/issues/3448
|
https://github.com/axios/axios/pull/3783
|
49509f6e95c20d3ad5af460b7e18e44325cf9391
|
69949a6c161d954570a314c0e48b57d3ffd90326
| 2020-11-29T07:23:23Z |
javascript
| 2021-05-14T14:08:36Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,407 |
["lib/adapters/http.js", "test/unit/regression/SNYK-JS-AXIOS-1038255.js"]
|
Possible bug: Vulnerability SSRF
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
In my current project we are using Snyk to catch any possible issues and vulnerabilities.
Snyk reports that since version 0.19.0 there is SSRF vulnerability that has no been fixed yet.
This is the message:
``Affected versions of this package are vulnerable to Server-Side Request Forgery (SSRF). An attacker is able to bypass a proxy by providing a URL that responds with a redirect to a restricted host or IP address.``
Could you please verify?
Thanks in advance.
#### To Reproduce
Any pen tests or just using Snyk to scan any app that uses axios.
#### Expected behavior
No vulnerabilities alerts.
#### Environment
- Axios Version [0.21.0]
- Adapter [HTTP]
- Browser [All]
- Browser Version [x]
- Node.js Version [12.14.1]
- OS: [x]
- Additional Library Versions [x]
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/3407
|
https://github.com/axios/axios/pull/3410
|
f472e5da5fe76c72db703d6a0f5190e4ad31e642
|
c7329fefc890050edd51e40e469a154d0117fc55
| 2020-11-12T15:41:36Z |
javascript
| 2020-11-24T06:44:00Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,374 |
["lib/defaults.js", "test/unit/defaults/transformReponse.js"]
|
Do not apply data tansformation to the empty 204 status code responses
|
#### Describe the bug
For responses with status code 204 Chrome debugger catch exception and stop application debugging in empty string parse catch. We need to avoid obvious error catching.
#### To Reproduce
If I set pause on exceptions in Chrome debugger and response has status code 204 axios always do data transformation and paused in place where it is trying to parse empty string:
` transformResponse: [function transformResponse(data) {
/*eslint no-param-reassign:0*/
if (typeof data === 'string') {
try {
data = JSON.parse(data);
} catch (e) { /* Ignore */ }
}
return data;
}],`
Of course I can override transformResponse, but it is not very user friendly. So instead I suggest just to add additional check here:
https://github.com/axios/axios/blob/768825589fd0d36b64a66717ca6df2efd8fb7844/lib/core/dispatchRequest.js#L55
```
if (response.status !== 204) {
// Do transformation
}
```
I think this is a good solution as http status code 204 mean an empty response body and it will save one extra parsing that is catching the error. Is there any other thoughts on this?
#### Expected behavior
No data transformation should happen for responses with status code 204.
#### Environment
- Axios Version [e.g. 0.18.0]
- Adapter [e.g. XHR/HTTP]
- Browser [e.g. Chrome, Safari]
- Browser Version [e.g. 22]
- Node.js Version [e.g. 13.0.1]
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

|
https://github.com/axios/axios/issues/3374
|
https://github.com/axios/axios/pull/3377
|
364867edd295b5ea0019b4e70fd37be5a5b751ee
|
f2057f77b231d88ea94ad88e84e4fd9f99506880
| 2020-10-30T23:26:47Z |
javascript
| 2021-03-24T06:22:03Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,369 |
["lib/adapters/http.js", "test/unit/regression/SNYK-JS-AXIOS-1038255.js"]
|
Requests that follow a redirect are not passing via the proxy
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
In cases where `axios` is used by servers to perform http requests to user-supplied urls, a proxy is commonly used to protect internal networks from unauthorized access and [SSRF](https://en.wikipedia.org/wiki/Server-side_request_forgery). This bug enables an attacker to bypass the proxy by providing a url that responds with a redirect to a restricted host/ip.
#### To Reproduce
The following code spawns a proxy server that *always* responds with a 302 redirect, so requests should never reach the target url, however, `axios` is only reaching the proxy once, and bypassing the proxy after the redirect response.
https://runkit.com/embed/1df5qy8lbgnc
```js
const axios = require('axios')
const http = require('http')
const PROXY_PORT = 8080
// A fake proxy server
http.createServer(function (req, res) {
res.writeHead(302, {location: 'http://example.com'})
res.end()
}).listen(PROXY_PORT)
axios({
method: "get",
url: "http://www.google.com/",
proxy: {
host: "localhost",
port: PROXY_PORT,
},
})
.then((r) => console.log(r.data))
.catch(console.error)
```
The response is the rendered html of _http://example.com_
#### Expected behavior
*All* the requests should pass via the proxy. In the provided scenario, there should be a redirect loop.
#### Environment
- Axios Version [0.21.0]
- Node.js Version [v12.18.2]
#### Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
|
https://github.com/axios/axios/issues/3369
|
https://github.com/axios/axios/pull/3410
|
f472e5da5fe76c72db703d6a0f5190e4ad31e642
|
c7329fefc890050edd51e40e469a154d0117fc55
| 2020-10-29T14:37:32Z |
javascript
| 2020-11-24T06:44:00Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,286 |
["lib/adapters/xhr.js", "test/specs/__helpers.js"]
|
RequestHeaders.Authorization parameter concatenation failed
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
In situations that use Basic auth and do not pass the parameter "password" _**requestHeaders.Authorization**_ is concatenated unduly "**: undefined**".
#### To Reproduce
Any request using **Basic Authentication** without passing the parameter "**password**" as an example below.
```js
var axios = require("axios")
const instance = axios.create();
instance.request({
method: 'POST',
baseURL: ".../XPTO",
auth: { username: "janedoe" }}
).then(
// do something
);
```
#### Expected behavior
To maintain compatibility with previous versions, the proper behavior would be to test if the parameter "**password**" was passed, otherwise concatenate empty.
#### Environment
- Axios Version [e.g. 0.20.0]
- Adapter [e.g. XHR/HTTP]
- Browser [e.g. Chrome, Safari]
- Browser Version [e.g. 22]
- Node.js Version [e.g. 13.0.1]
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]
#### Additional context/Screenshots
A problem arising from the lack of compatibility with previous versions is to force all current projects that do not pass a "password" parameter to have to include this parameter with an empty value.
|
https://github.com/axios/axios/issues/3286
|
https://github.com/axios/axios/pull/3287
|
e8c6e191410b05c496637768301debdcb7669c65
|
04d45f20911a02e9457db9e9d104aa156e170b11
| 2020-09-13T20:06:38Z |
javascript
| 2020-09-20T02:19:48Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,232 |
["lib/adapters/xhr.js"]
|
Developer set Content type header deleted if data is blob/file. (Caused by #1773)
|
#### Describe the bug
I have a chunked file uploader, all data is to be sent as application/octet-stream in PUT in a binary stream.
This worked in 0.19.2.
However, 0.20.0 fails because of code added under #1773 "Fixing overwrite Blob/File type as Content-Type in browser.".
Line 21 lib/adapters/xhr.js:
```
if (
(utils.isBlob(requestData) || utils.isFile(requestData)) &&
requestData.type
) {
delete requestHeaders['Content-Type']; // Let the browser set it
}
```
This "fix" now breaks my application as it assumes the browser knows best - it doesn't. It also is semantically inaccurate to set the content type to something like image/jpeg when the data is 20MB chunk from the middle of a jpeg file - the data is NOT of content type image/jpeg.
The "fix" applied in #1773 appears to be fixing overwrite caused by setting of default content-type headers but this solution removes ANY control over the header by the developer when dealing with Blobs.
#### To Reproduce
Simply set content-type in a request where the payload is a blob.
#### Expected behavior
Axios should NOT delete the content type header set by the developer specifically on the request. The power to control this should remain with the calling code and not be dictated by the library.
#### Environment
- Axios Version 0.20.0
- Adapter XHR
- Browser ALL
- Browser Version ALL
- Node.js Version n/a
- OS: ALL (Linux, Windows, mac)
#### Additional context/Screenshots
|
https://github.com/axios/axios/issues/3232
|
https://github.com/axios/axios/pull/3289
|
6d05b96dcae6c82e28b049fce3d4d44e6d15a9bc
|
9a78465a9268dcd360d7663de686709a68560d3d
| 2020-08-26T10:34:11Z |
javascript
| 2020-10-13T08:19:37Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,220 |
["lib/core/Axios.js", "test/specs/requests.spec.js"]
|
Axios does not use data from config when making DELETE request
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
#### Describe the bug
Axios last version (0.20.0) does not use data from config when making DELETE request. In 0.19.2 it's working fine
#### To Reproduce
```js
axios.delete("...", {
data: { ids: [...] },
}).then(response => {
...
}).catch(error => {
...
});
```
#### Expected behavior
Axios send request data from config when making DELETE request
#### Environment
- Axios Version 0.20.0
- Browser Chrome
- Browser Version 84.0.4147.125
- Node.js Version 12.18.3
- OS: Linux Mint
- Additional Library Versions React 16.13.1
#### Additional context/Screenshots
None
|
https://github.com/axios/axios/issues/3220
|
https://github.com/axios/axios/pull/3282
|
b7e954eba3911874575ed241ec2ec38ff8af21bb
|
fa3673710ea6bb3f351b4790bb17998d2f01f342
| 2020-08-21T09:04:05Z |
javascript
| 2020-10-01T07:46:32Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,219 |
["index.d.ts"]
|
Cannot find name 'ProgressEvent' when compiling TypeScript
|
#### Describe the bug
When trying to compile a Firebase function (Node.js / TypeScript) I get an error:
```js
node_modules/axios/index.d.ts:62:38 - error TS2304: Cannot find name 'ProgressEvent'.
62 onUploadProgress?: (progressEvent: ProgressEvent) => void;
~~~~~~~~~~~~~
node_modules/axios/index.d.ts:63:40 - error TS2304: Cannot find name 'ProgressEvent'.
63 onDownloadProgress?: (progressEvent: ProgressEvent) => void;
~~~~~~~~~~~~~
```
#### To Reproduce
Example of a `package.json` that fails to compile using `npm run build`.
```js
{
"name": "functions",
"scripts": {
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
"lint-fix": "eslint -c .eslintrc.js --fix --ext .ts ./src",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"firebase": "firebase serve --only functions --port=8080",
"deploy": "npm run build && npm run lint && firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"axios": "^0.20.0",
"firebase-functions": "^3.10.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.9.1",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.0.5",
"typescript": "^3.9.7"
},
"private": true,
"engines": {
"node": "10"
}
}
```
#### Expected behavior
The Node.js code should compile.
#### Environment
- Axios Version: 0.20.0
- Node.js Version: 10.21.0
- OS: Ubuntu 20.04
#### Additional context/Screenshots
None.
|
https://github.com/axios/axios/issues/3219
|
https://github.com/axios/axios/pull/3237
|
04d45f20911a02e9457db9e9d104aa156e170b11
|
b7e954eba3911874575ed241ec2ec38ff8af21bb
| 2020-08-21T06:59:30Z |
javascript
| 2020-10-01T07:42:09Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,163 |
["README.md"]
|
It's not documented what happens if request is started with already cancelled token.
|
#### Section/Content To Improve
https://github.com/axios/axios#cancellation
#### Suggested Improvement
Document what will happen if I pass already cancelled token to axios request. Will it try to make a request ?
#### Relevant File(s)
no
|
https://github.com/axios/axios/issues/3163
|
https://github.com/axios/axios/pull/3803
|
69949a6c161d954570a314c0e48b57d3ffd90326
|
3958e9fbc8ebc0f72a8ce568cbf86f391d6869f3
| 2020-08-01T12:41:56Z |
javascript
| 2021-05-18T07:08:20Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,140 |
["README.md", "index.d.ts"]
|
Misleading verbiage around supported HTTP methods
|
#### Section/Content To Improve
Section: Request method aliases
Quote: "For convenience aliases have been provided for all supported request methods."
#### Suggested Improvement
The key word in the quote is "supported". This suggests to me that anything not listed is not supported. `search` is not in the list, which implies that the SEARCH method is not supported. However, I tried the following:
```
axios.request({
url: 'testing',
method: 'search'
});
```
and it successfully sent a SEARCH request. This shows that the SEARCH method is actually supported. So, I would change the word "supported" to "common". And while we are at it, there needs to be a comma after "convenience". So the improved quote would read:
"For convenience, aliases have been provided for all common request methods."
#### Relevant File(s)
https://github.com/axios/axios/blob/master/README.md
|
https://github.com/axios/axios/issues/3140
|
https://github.com/axios/axios/pull/3802
|
224ed940e15b615336bc104b3478b137f7a48b86
|
8e67551177990ed067384e1641d6964dcab773f7
| 2020-07-22T13:30:42Z |
javascript
| 2022-03-08T06:26:07Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 3,017 |
["index.d.ts"]
|
Align auto-import with README examples
|
**Is your feature request related to a problem? Please describe.**
When you copy'n'paste examples from the README into you code, you can't easily auto-import (e.g. in VS Code) the Axios lib.
**Describe the solution you'd like**
I'll rename the default export in the `index.d.ts` so it alignes with the official documentation.
Change this:


To this:


**Describe alternatives you've considered**
Change all the official examples to use `Axios` instead of `axios` ;)
**Additional context**
Nothing.
|
https://github.com/axios/axios/issues/3017
|
https://github.com/axios/axios/pull/2797
|
94ca24b5b23f343769a15f325693246e07c177d2
|
820fe6e41a96f05fb4781673ce07486f1b37515d
| 2020-06-12T09:14:53Z |
javascript
| 2020-10-27T12:36:32Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,819 |
["lib/core/Axios.js", "lib/core/dispatchRequest.js", "lib/core/mergeConfig.js", "lib/utils.js", "test/specs/core/mergeConfig.spec.js", "test/specs/headers.spec.js", "test/specs/requests.spec.js", "test/specs/utils/deepMerge.spec.js", "test/specs/utils/isX.spec.js", "test/specs/utils/merge.spec.js"]
|
Param with value of null is replaced with "{}"
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
**Describe the bug**
Param with value of null is replaced with "{}"
**To Reproduce**
axios.get('/whatever', {params: {test: null}}) used to make GET request to /whatever, now it's /whatever?test=%7B%7D
**Expected behavior**
Should request to /whatever.
**Environment:**
- Axios Version [the current master]
**Additional context/Screenshots**
See https://github.com/axios/axios/pull/2656#issuecomment-598269460.
|
https://github.com/axios/axios/issues/2819
|
https://github.com/axios/axios/pull/2844
|
487941663b791a4a5273d456aab24c6ddd10eb0e
|
0d69a79c81a475f1cca6d83d824eed1e5b0b045d
| 2020-03-13T02:13:21Z |
javascript
| 2020-06-08T18:52:45Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,777 |
["README.md"]
|
Update ' sign to ` in proxy spec
|
**Section/Content To Improve**
Link: https://github.com/axios/axios#request-config
```
// 'proxy' defines the hostname and port of the proxy server.
```
The ' sign should be `
```
// `proxy` defines the hostname and port of the proxy server.
```
**Suggested Improvement**
Just update ' sign to `
**Relevant File(s)**:
- README.md
|
https://github.com/axios/axios/issues/2777
|
https://github.com/axios/axios/pull/2778
|
17a967123cc1c06f15146a463b99816d4ca5f2b2
|
3d6cafb3f79cccbcee26312c86d75d7fd83909b2
| 2020-02-25T09:01:58Z |
javascript
| 2020-02-25T15:05:51Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,691 |
["lib/adapters/http.js", "package.json"]
|
Let's establish a closer relation with follow-redirects
|
Hi axios maintainers,
I'm the maintainer of follow-redirects. According to npm numbers (https://www.npmjs.com/package/axios, https://www.npmjs.com/package/follow-redirects), more than half of follow-redirects usage goes via axios. That is also apparent from several [bug reports](https://github.com/follow-redirects/follow-redirects/issues?q=axios) I received (and which I'm very happy about).
So if there are issues such as https://github.com/axios/axios/pull/1993 or https://github.com/axios/axios/pull/2689, it's probably best to ping us about it at https://github.com/follow-redirects/follow-redirects/issues/new. I'm very happy to fix. Pinning to an old version of follow-redirects will just expose you to bugs.
Please let me know how I can help.
CC: @grumblerchester @emilyemorehouse @realityking @chinesedfan
|
https://github.com/axios/axios/issues/2691
|
https://github.com/axios/axios/pull/2689
|
77f0ae4f61e04ec5982eba171b1b7bb0b94569b7
|
56b72bbd2c2924ff6d89a7004282142d86ead8fa
| 2020-01-25T22:01:37Z |
javascript
| 2020-02-15T05:41:08Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,665 |
["lib/adapters/http.js"]
|
[Bug] Axios crashes on HEAD method and gziped repsonse
|
**To Reproduce**
Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue.
```js
const axios = require("axios")
const url = 'https://stackoverflow.com/questions';
const {headers} = await axios.head(url, {
headers: {'accept-encoding': 'gzip, deflate, br'}
});
```
You can run this in one click here https://runkit.com/embed/eocb5097ds6r
**Expected behavior**
Don't crush
**Environment:**
- Node.js any version
**Solution:**
It require trivial fix similar to https://github.com/axios/axios/pull/1129
|
https://github.com/axios/axios/issues/2665
|
https://github.com/axios/axios/pull/2666
|
2034c1db7eaac61fabd4319af2e9b4478d1d6b52
|
12e00b8018ddfb078800ebc548879723665b4bce
| 2020-01-15T08:59:43Z |
javascript
| 2020-02-15T10:10:58Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,646 |
["lib/helpers/isURLSameOrigin.js", "lib/helpers/isValidXss.js", "test/specs/helpers/isURLSameOrigin.spec.js", "test/specs/helpers/isValidXss.spec.js"]
|
Requests to urls containing 'javascript' are failing
|
It seems that axios v0.19.1 introduced a new bug.
The bug comes from https://github.com/axios/axios/pull/2464
All urls containing `javascript`keyword is throwing XSS error. So, all following urls cannot be used in axios any more:
- https://www.javascript.com
- https://stackoverflow.com/questions/tagged/javascript
- https://www.google.com/search?q=javascript
Here is a link to regexp: https://regexr.com/4rsst
Expected behavior: axios should accept `javascript` in urls
|
https://github.com/axios/axios/issues/2646
|
https://github.com/axios/axios/pull/2679
|
351cf290f0478d6e47e74c6da2f3ad8fe8f29887
|
c7488c7dd5ea697facc96202417cd1c4363a4ee7
| 2020-01-09T09:00:07Z |
javascript
| 2020-01-20T16:20:33Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,594 |
["test/unit/adapters/http.js"]
|
Unit test fails when excuting the unit test in Windows OS
|
**Describe the bug**
Unit test case failed :
1) supports http with nodejs
should pass errors for a failed stream:
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (***************...
**To Reproduce**
Use VS Code internal terminal to excute the unit test .
**Expected behavior**
UT should be excuted correctly.
**Environment:**
- Axios Version: latest master
- OS Version: Window 10
**Additional context/Screenshots**

|
https://github.com/axios/axios/issues/2594
|
https://github.com/axios/axios/pull/2601
|
12e00b8018ddfb078800ebc548879723665b4bce
|
9267d4def1a3c65b2d2bbb051b11d74f25ea00ae
| 2019-12-09T12:40:14Z |
javascript
| 2020-02-15T11:03:34Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,593 |
["README.md"]
|
Revert changes about `finally`
|
<!-- Click "Preview" for a more readable version --
If you found an area that needs clarification, feel free to open a PR or list the section/content that could be improved below
โ ๏ธ๐ Feel free to refer to these instructions before submitting the issue ๐โ ๏ธ
-->
**Section/Content To Improve**
https://github.com/axios/axios/blob/master/README.md#note-commonjs-usage
**Suggested Improvement**
See https://github.com/axios/axios/pull/2305#pullrequestreview-266978437. Revert #2189 and #2090.
**Relevant File(s)**: README.md
|
https://github.com/axios/axios/issues/2593
|
https://github.com/axios/axios/pull/2683
|
2a0ff479f9fb7f09a219f5178ca85a6519562ff1
|
7df84a7ff7c2d33b0f210608a489db7b5fc0df37
| 2019-12-08T11:36:27Z |
javascript
| 2020-01-22T20:18:22Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,484 |
["CHANGELOG.md"]
|
Update doc on 0.19.0
|
<!-- Click "Preview" for a more readable version --
If you found an area that needs clarification, feel free to open a PR or list the section/content that could be improved below
โ ๏ธ๐ Feel free to refer to these instructions before submitting the issue ๐โ ๏ธ
-->
**Section/Content To Improve**
Changelog 0.19.0
**Suggested Improvement**
We are using axios in our application and had the problem that the no_proxy environment variable was not correctly used.
I saw this was fixed in 0.19.0-beta.1 back in august 2018.
Howevern in the change and release notes of 0.19.0 there was no mention of those fixes, they were still only mentioned for the beta release.
Therefore it was hard for me to decide whether I should use 0.19.0 or the beta version.
**Relevant File(s)**: [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
|
https://github.com/axios/axios/issues/2484
|
https://github.com/axios/axios/pull/2513
|
b0afbedf1b0c4e3d4b9991028e61fa39b886ae13
|
86d77504c2712ffd787873d0642e62a4e4c5de10
| 2019-10-23T12:18:08Z |
javascript
| 2019-11-04T04:54:19Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,468 |
["lib/core/Axios.js", "test/specs/api.spec.js", "test/specs/instance.spec.js"]
|
axios.getUri doesn't use baseURL
|
**Describe the bug**
When using https://github.com/axios/axios/pull/1712 example and adding baseURL in config, baseURL seems to not be used.
**To Reproduce**
```js
const axios = require("axios");
const fakeConfig = {
method: "post",
url: "/user/12345",
baseURL: "/foo"
};
console.log(axios.getUri(fakeConfig));
```
**Expected behavior**
`axios.getUri` should return `/foo/user/12345`.
If this expected behavior seems right, I can work on a fix.
**Environment:**
- Axios Version: 0.19.0
- OS: Linux, Windows
- Browser Chrome but also happen on Firefox and node
|
https://github.com/axios/axios/issues/2468
|
https://github.com/axios/axios/pull/3737
|
195c8e5ff5af6506e5c3e9423cd3c6e839b9cc86
|
bdb7d76d40407443dceaf9efa5d5a01ee4ef4da5
| 2019-10-15T16:20:17Z |
javascript
| 2022-03-07T18:09:23Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,416 |
["lib/core/settle.js", "test/specs/requests.spec.js"]
|
Getting local files (file://) fail after upgrading from 0.18.0 to 0.19.0
|
**Describe the bug**
When using axios to get a local file (`file://...`) I get status code 0 as if there's a CORS issue. This didn't happen using version 0.18.0 so I assume that this is a bug?
**To Reproduce**
Get a local file. In my case I wanted to get a PDF as an array buffer.
```js
axios("file://...", {
responseType: 'arraybuffer'
headers: {
Accept: 'application/pdf'
}
}).then(..)
```
**Expected behavior**
Just like in version 0.18.0 version I should get a 200 response.
**Environment:**
- Axios Version 0.19.0
- OS: Windows 10
- Browser: EO Webbrowser (Chromium)
- Browser Version: 19.1.95 (Chromium ~70)
- Additional Library Versions: React 16.8.6
**Additional context/Screenshots**
Need to build and run index.html locally so you're making the request from file:// as well.
|
https://github.com/axios/axios/issues/2416
|
https://github.com/axios/axios/pull/2470
|
5189afff38dc0689ac0c1b1bfa51626bb8541709
|
885ada6d9b87801a57fe1d19f57304c315703079
| 2019-09-16T15:53:56Z |
javascript
| 2020-03-23T13:49:38Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,396 |
["lib/core/settle.js", "test/specs/requests.spec.js"]
|
Regression in 0.19.0: file:/// that always returns a status code 0 now returns an error
|
**Describe the bug**
Since I upgrade axios from 0.18.0 to 0.19.0, the requests made to fetch a local file (`file:///`) with a relative path return an error: ```Request failed with status code 0```. However the web browser will always return a status code 0 when the request success because there is no HTTP server involved. The XHR readyState is also 4, if there was a network error, I believe this one would probably be 0 as well.
**To Reproduce**
```js
// In a HTML file like opened at file:///tmp/axios.html for example
axios.get('./file.ttf', {
responseType: 'arraybuffer',
}).then((resp) => {
console.log('OK', resp);
}).catch((err) => {
if (err.request && err.request.readyState === 4) {
// The response here should not be treated as an error
}
console.log('ERR', err);
});
```
**Expected behavior**
The request should success and return the arraybuffer (works with axios 0.18.0).
**Environment:**
- Axios Version: 0.19.0
- OS: iOS 12.4, OSX 10.14.6
- Browser: Safari
- Browser Version: 12.1.2
- Additional Library Versions: None
**Additional context/Screenshots**


|
https://github.com/axios/axios/issues/2396
|
https://github.com/axios/axios/pull/2470
|
5189afff38dc0689ac0c1b1bfa51626bb8541709
|
885ada6d9b87801a57fe1d19f57304c315703079
| 2019-09-07T11:33:13Z |
javascript
| 2020-03-23T13:49:38Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,387 |
["lib/core/Axios.js", "test/unit/adapters/http.js"]
|
Improve axios stack traces
|
Currently, if you use axios with async / await, you get a stack trace like this:
```
Request failed with status code 500
at createError (/Users/rmenezes/code/seedfi/web/node_modules/axios/lib/core/createError.js:16:15)
at settle (/Users/rmenezes/code/seedfi/web/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/Users/rmenezes/code/seedfi/web/node_modules/axios/lib/adapters/http.js:237:11)
at IncomingMessage.emit (events.js:208:15)
at IncomingMessage.EventEmitter.emit (domain.js:471:20)
at endReadableNT (_stream_readable.js:1154:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11
```
It doesn't show you much about *what* called Axios., which makes debugging quite difficult!
This is because `settle` calls `createError`:
https://github.com/axios/axios/blob/master/lib/core/settle.js#L12-L24
Which creates a new error with a brand new stack trace:
https://github.com/axios/axios/blob/master/lib/core/createError.js#L15-L18
Perhaps we can fix this by creating an error before the request goes out and stitching it to the new error's stack trace?
|
https://github.com/axios/axios/issues/2387
|
https://github.com/axios/axios/pull/5987
|
6d4c421ee157d93b47f3f9082a7044b1da221461
|
123f354b920f154a209ea99f76b7b2ef3d9ebbab
| 2019-09-03T19:10:11Z |
javascript
| 2024-01-24T22:21:12Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,385 |
[".travis.yml"]
|
Fix "Can't open /etc/init.d/xvfb" on travis.
|
<!-- Click "Preview" for a more readable version --
Please read and follow the instructions before submitting an issue:
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
โ ๏ธ๐ Feel free to these instructions before submitting the issue ๐โ ๏ธ
-->
**Describe the bug**
Error on run travis Ci Build "Can't open /etc/init.d/xvfb"
**To Reproduce**
Re-run last build
**Expected behavior**
Build run's without problem.
**Additional context/Screenshots**

|
https://github.com/axios/axios/issues/2385
|
https://github.com/axios/axios/pull/2386
|
2ee3b482456cd2a09ccbd3a4b0c20f3d0c5a5644
|
98e4acd893fe024ae9e6074894c6164802b3af63
| 2019-09-02T00:46:50Z |
javascript
| 2019-09-05T01:02:01Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,226 |
["README.md"]
|
axios commonjs correct way to import to gain typings? [vscode intellisense]
|
**Describe the issue**
what is the correct way to import `axios` in node using CommonJS in order to use the typings? i am not using typescript unlike [this issue](https://github.com/axios/axios/issues/1975)
**Example Code**
```js
const axios = require('axios'); // no typings but everything still works
const axios = require('axios').default; // has typings and everything works
```
**Expected behavior, if applicable**
i expected to have typings for vscode intellisense when importing `axios` using CommonJS `require()` syntax described in the documentation.
i did not see any information about having to append `.default` to the import. maybe worth including this in the docs? for the record the import still works (`axios.get()` etc) but there is no typing intellisense.
**Environment:**
- Axios Version: 0.19.0
- OS: OSX 10.14.5
- node: 10.15.3
- vscode: 1.34.0
**Additional context/Screenshots**
Add any other context about the problem here. If applicable, add screenshots to help explain.
**basic import**
<img width="746" alt="Screen Shot 2019-06-13 at 12 29 23 AM" src="https://user-images.githubusercontent.com/25523682/59403834-61e9a100-8d72-11e9-9c53-0dd50a14e38e.png">
**import with `.default`**
<img width="747" alt="Screen Shot 2019-06-13 at 12 29 34 AM" src="https://user-images.githubusercontent.com/25523682/59403848-68781880-8d72-11e9-8d96-c8acabd56a2b.png">
|
https://github.com/axios/axios/issues/2226
|
https://github.com/axios/axios/pull/2256
|
488a4598a3eedc5bf99a6df0bbd07d1cbd8bb1a4
|
e3a7116f14e7bbb7c3645df5d7910642c8fc2f5e
| 2019-06-13T04:35:43Z |
javascript
| 2019-09-13T12:28:14Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,203 |
["lib/core/mergeConfig.js", "test/specs/core/mergeConfig.spec.js"]
|
Custom properties for config
|
So, if I understand it right, in 0.19.0 you've added `mergeConfig`
And this function filter config and remove custom properties from it.
It broke my solution for cancellation:
How it works:
```js
const requestManager = new RequestManager();
const instance = axios.create();
requestManager.patchAxiosInstance(instance);
const search = q =>
instance.get('/search', {
cancelable: true, // this is no longer possible in 0.19.0
params: { q },
});
```

The solution:
```js
class RequestManager {
constructor() {
this.pendingRequests = new Map();
}
patchAxiosInstance(instance) {
instance.interceptors.request.use(config => {
if (!config.cancelable) return config; // this is no longer possible in 0.19.0
const source = axios.CancelToken.source();
const requestId = `${config.method}_${config.url}`;
const cancelToken = source.token;
this.addRequest(requestId, source.cancel);
return { ...config, cancelToken, requestId };
});
instance.interceptors.response.use(response => {
const { requestId } = response.config; // this is no longer possible in 0.19.0
if (requestId) {
this.removeRequest(requestId);
}
return response;
});
}
addRequest(requestId, cancelFn) {
this.cancelRequest(requestId);
this.pendingRequests.set(requestId, cancelFn);
}
removeRequest(requestId) {
this.pendingRequests.delete(requestId);
}
cancelRequest(requestId) {
if (this.pendingRequests.has(requestId)) {
const cancelFn = this.pendingRequests.get(requestId);
cancelFn();
this.removeRequest(requestId);
}
}
}
```
So, is it possible to relax filter in `mergeConfig` for custom properties? Because sometimes it is needed and very helpful in interceptors or somewhere else.
|
https://github.com/axios/axios/issues/2203
|
https://github.com/axios/axios/pull/2207
|
e50a08b2c392c6ce3b5a9dc85ebc860d50414529
|
a11cdf468303a365a6dc6e84f6dd0e4b3b8fd336
| 2019-06-05T13:43:07Z |
javascript
| 2019-09-07T00:40:04Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,195 |
["lib/defaults.js"]
|
0.19.0 no longer works with xhr-mock
|
**Describe the bug**
Running Jest unit tests with xhr-mock https://github.com/jameslnewell/xhr-mock fail. Reverting to 0.18.0 fixed it.
|
https://github.com/axios/axios/issues/2195
|
https://github.com/axios/axios/pull/2201
|
c454e9f526bad399bd2a92af7fa8bc97a6d1acd0
|
1b07fb9365d38a1a8ce7427130bf9db8101daf09
| 2019-05-31T15:45:18Z |
javascript
| 2019-09-13T12:35:59Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,158 |
["README.md"]
|
Clarification: Only Basic auth
|
**Section/Content To Improve**
[Request Config](https://github.com/axios/axios#request-config)
**Suggested Improvement**
On the 'auth' option are said:
> `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
> This will set an `Authorization` header, overwriting any existing
> `Authorization` custom headers you have set using `headers`.
I think that need more clarification that bearer token auth, for example, will don't work
|
https://github.com/axios/axios/issues/2158
|
https://github.com/axios/axios/pull/2166
|
5250e6e168f22bf75f0643b21577ac7c4dc486b9
|
f28ff933e491ad7b1dd77af6ad3abe126109bd9e
| 2019-05-17T03:04:37Z |
javascript
| 2019-05-28T16:57:59Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,154 |
["lib/defaults.js", "test/specs/headers.spec.js", "test/unit/adapters/http.js"]
|
Content-type header for application/json should not contain charset field, according do RFC 8259
|
**Describe the bug**
According to [RFC 8259 - The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc7159) content-type `application/json` does not have any charset defined, as it must be utf-8 encoded. Older specifications allowed other unicode encodings, and parsers were detecting exact encoding used by first four bytes, still not by charset param.
Axios defaults to header `Content-Type: application/json;charset=utf-8` for some types of sent data.
This breaks some HTTP servers and applications, who are not recognizing the content-type.
**To Reproduce**
```js
axios.post("http://example.com", {an: "object"});
// Content-Type: application/json;charset=utf-8 header will be set
```
**Expected behavior**
`Content-Type: application/json` header should be set as default for object data, without charset parameter.
**Environment:**
- Axios Version - 0.18.0, I've also checked master branch source - it is still there.
https://github.com/axios/axios/blob/b4c5d35d2875191dfa8c3919d4227dce8e2ad23f/lib/defaults.js#L52
**Additional context/Screenshots**
This breaks some parts of the rabbitmq-management API.
Related issues:
https://github.com/axios/axios/issues/859
|
https://github.com/axios/axios/issues/2154
|
https://github.com/axios/axios/pull/3807
|
3958e9fbc8ebc0f72a8ce568cbf86f391d6869f3
|
dbc634cf700595845abc43604e1fb6cea903b97f
| 2019-05-14T16:40:29Z |
javascript
| 2021-05-21T05:51:31Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,153 |
["README.md", "index.d.ts", "lib/adapters/http.js", "test/unit/adapters/http.js"]
|
Add option to not auto decompress resp
|
**Is your feature request related to a problem? Please describe.**
It's frustrating there's no option to turn off decompress. There are situations where you want to do this. Ex: having a service that collects data, but doesn't analyze it. which then passes to another service immediately/eventually.
While data is waiting or in traffic to next stop, it should stay compressed. The difference in byte size is huge (for me, 60MB vs 1-2MB).
**Describe the solution you'd like**
Add an option to the request to not automatically decompress for me. I'm a big boy, I can handle it myself later.
**Describe alternatives you've considered**
There are none except user another lib or write own http req (which is ridiculous just to turn off a auto feature).
I can submit a PR if no one else wants to do it (it's not hard to add). But let me know how you'd like the option to be passed in? An extra options key? `axios({ url: ..., method: ..., decompress: false })` , or adding option to an existing option?
|
https://github.com/axios/axios/issues/2153
|
https://github.com/axios/axios/pull/2661
|
6642ca9aa1efae47b1a9d3ce3adc98416318661c
|
42eb9dfabc85ed029462da1c503f8b414b08ffd0
| 2019-05-14T15:35:37Z |
javascript
| 2020-03-06T14:01:58Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,103 |
["lib/adapters/xhr.js"]
|
Error: timeout of 0ms exceeded
|
Sentry reported a random error coming from Axios, `Error: timeout of 0ms exceeded`.
Under what circumstances would this error appear? We don't have timeout settings configured, and 0ms seems like a mighty short time for any request to finish, so why is this error thrown?
It appears to have been a one off that is not readily reproducible, so I can't provide test code, but the underlying network error seems to have been `ECONNABORTED`.
Axios version 0.18.0
|
https://github.com/axios/axios/issues/2103
|
https://github.com/axios/axios/pull/3209
|
e52cd3ac6439237414a17ab6f37d8a50df6d989b
|
96956e30ba2768b754d53125af832c9ccf66a9cd
| 2019-04-20T21:23:45Z |
javascript
| 2021-09-16T19:16:43Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 2,049 |
["README.md"]
|
Using multipart/form-data
|
**Section/Content To Improve**
*Using multipart/form-data* (to upload files and raw data.)
**Suggested Improvement**
Add the section
**Relevant File(s)**:
README.md
----------------
###
### Upload multipart/form-data
```js
let FormData = require( 'form-data' );
```
*The `form-data` package has some extra features compared to the native formData class, which we'll use*
Create a new FormData object, add content.
```js
// Random 8-bit (uint) data.
let dataInBuffer = new Buffer.from( [0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0xFF] );
let formData = new FormData();
formData.append( 'id', 1 );
formData.append( 'string', 'Text we want to add to the submit' );
formData.append( 'file', dataInBuffer, {
filename: 'someFileName.bin',
contentType: 'application/octet-stream',
} );
```
Axios does not turn the formData object in a proper Buffer/stream. We need to do this manually.
Turn the formData object into a Buffer, so Axios can handle it.
```js
let formDataToBufferObject = formDataToBuffer( formData );
```
A proper multipart/form-data request has a header for each parameter. Each header consists of `--boundary`.
The `form-data` package automatically creates these headers, including all breaks `\r\n` needed. We do however
need to add a break after our data. Below code will handle it for us.
```js
function formDataToBuffer( formData ) {
let dataBuffer = new Buffer( 0 );
let boundary = formData.getBoundary();
for( let i = 0, len = formData._streams.length; i < len; i++ ) {
if( typeof formData._streams[i] !== 'function' ) {
dataBuffer = this.bufferWrite( dataBuffer, formData._streams[i] );
// The item have 2 more "-" in the boundary. No clue why
// rfc7578 specifies (4.1): "The boundary is supplied as a "boundary"
// parameter to the multipart/form-data type. As noted in Section 5.1
// of [RFC2046], the boundary delimiter MUST NOT appear inside any of
// the encapsulated parts, and it is often necessary to enclose the
// "boundary" parameter values in quotes in the Content-Type header
// field."
// This means, that we can use the boundary as unique value, indicating that
// we do NOT need to add a break (\r\n). These are added by data-form package.
//
// As seen in this example (https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST#Example)
// the boundary is preceded by 2x "-". If thus --Boundary exists, do not add the break.
if( typeof formData._streams[i] !== 'string' || formData._streams[i].substring( 2, boundary.length + 2 ) !== boundary ) {
dataBuffer = this.bufferWrite( dataBuffer, "\r\n" );
}
}
}
// Close the request
dataBuffer = this.bufferWrite( dataBuffer, '--' + boundary + '--' );
return dataBuffer;
}
// Below function appends the data to the Buffer.
function bufferWrite( buffer, data ) {
let addBuffer;
if( typeof data === 'string' ) {
addBuffer = Buffer.from( data );
}
else if( typeof data === 'object' && Buffer.isBuffer( data ) ) {
addBuffer = data;
}
return Buffer.concat( [buffer, addBuffer] );
}
```
Finally, provide the buffer to Axios. Make sure to set the header as well!
```js
axios.post( 'https://example.com/path/to/api',
formDataToBufferObject,
formData.getHeaders()
)
...
```
or if you want to specify your own headers
```js
axios.post( 'https://example.com/path/to/api',
formDataToBufferObject,
{
headers: {
User_Agent: 'Some Useragent',
Accept: 'application/json',
'Content-Type': formData.getHeaders()['content-type'],
},
} )
...
```
|
https://github.com/axios/axios/issues/2049
|
https://github.com/axios/axios/pull/2805
|
c120f44d3d29c8e822a92e1d6879b8b77be6b9dc
|
5e0fb5fc998d7f9f5a897363977b42f4fa047238
| 2019-03-20T12:20:45Z |
javascript
| 2020-04-05T10:01:38Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,990 |
["test/typescript/axios.ts"]
|
interface AxiosInstance is missing 'options' method
|
```typescript
export interface AxiosInstance {
(config: AxiosRequestConfig): AxiosPromise;
(url: string, config?: AxiosRequestConfig): AxiosPromise;
defaults: AxiosRequestConfig;
interceptors: {
request: AxiosInterceptorManager<AxiosRequestConfig>;
response: AxiosInterceptorManager<AxiosResponse>;
};
request<T = any>(config: AxiosRequestConfig): AxiosPromise<T>;
get<T = any>(url: string, config?: AxiosRequestConfig): AxiosPromise<T>;
delete(url: string, config?: AxiosRequestConfig): AxiosPromise;
head(url: string, config?: AxiosRequestConfig): AxiosPromise;
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
}
```
This is missing a line which should be
`options(url: string, config?: AxiosRequestConfig): AxiosPromise;`
|
https://github.com/axios/axios/issues/1990
|
https://github.com/axios/axios/pull/1996
|
42eb9dfabc85ed029462da1c503f8b414b08ffd0
|
c98ce7d464488dd59a6987cfaf08a4c7b31b96a2
| 2019-02-06T15:50:54Z |
javascript
| 2020-03-07T06:10:34Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,953 |
["package.json"]
|
`should support max redirects` mocha test fails
|
Seems like the `should support max redirect` mocha test is failing right away.
The checks are done in follow-redirects dep. that has been updated 6 days ago. Might have something to do with that maybe? See recent [commits](https://github.com/follow-redirects/follow-redirects/commits/master) to follow-redirects
|
https://github.com/axios/axios/issues/1953
|
https://github.com/axios/axios/pull/1993
|
e122c80c9ddb17e4dad2b6225da2ed9e95e986c7
|
2eeb59af4de41e07c7dd1eec09af0230960c029c
| 2019-01-09T07:27:10Z |
javascript
| 2019-02-09T04:27:36Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,863 |
["index.d.ts", "lib/axios.js", "lib/helpers/isAxiosError.js", "test/specs/api.spec.js", "test/specs/helpers/isAxiosError.spec.js", "test/specs/instance.spec.js", "test/typescript/axios.ts"]
|
Add a typeguard for discriminating AxiosError type from Error type
|
#### Summary
It would be nice to export a typeguard from Axios' index.d.ts.
This way, consumers trying to do error handling can check in a type-safe way if the error is an AxiosError, or some other kind of error.
It's easy enough to do this as a consumer, but it would be nicer if this was included in the actual Axios library.
|
https://github.com/axios/axios/issues/1863
|
https://github.com/axios/axios/pull/2949
|
768825589fd0d36b64a66717ca6df2efd8fb7844
|
f472e5da5fe76c72db703d6a0f5190e4ad31e642
| 2018-11-01T21:59:42Z |
javascript
| 2020-11-03T08:01:07Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,828 |
["package-lock.json"]
|
Request defaults
|
#### Summary
There is no way of knowing the defaults of request , i've searched `baseURL` default everywhere in the code and there is no way of knowing that, it is also does not mentioned in the Docs or COOKBOOK.
from sending a relative request i see that the baseURL is 127.0.0.1 but from where `axios` retrieve that information ? and how does it build the `url` assuming i did not passed a `config` when creating a axios instance?
#### Context
- axios version: 0.18.0
- Environment: node : v8.10.0 Ubuntu 16.04
|
https://github.com/axios/axios/issues/1828
|
https://github.com/axios/axios/pull/4615
|
008dd9d466167e97727bdba13f4937bb9d7f3baa
|
f94dda9c76442ac097923fdfc02199e72c20f083
| 2018-10-14T15:26:50Z |
javascript
| 2022-04-25T06:04:07Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,788 |
[".eslintrc.js"]
|
.eslintrc without extension is deprecated
|
#### Summary
.eslintrc without extension is deprecated (https://eslint.org/docs/user-guide/configuring#configuration-file-formats).
Though it is not a critical situation, add the extension will prevent a future development warning in case linters decide ti drop support to .eslintrc without extension.
To fix it, I suggest change the content to a js module (to allow comments). No other change is required.
#### Context
All
|
https://github.com/axios/axios/issues/1788
|
https://github.com/axios/axios/pull/1789
|
a74ab87df22a04932bcb1cc91d05dd0b2fa4ae9e
|
81f0d28eb5f8f3ec606fe0e282d4fbaea109c868
| 2018-09-13T12:10:28Z |
javascript
| 2018-09-17T14:24:46Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,656 |
["karma.conf.js", "lib/adapters/xhr.js", "lib/core/settle.js", "lib/helpers/btoa.js", "test/specs/__helpers.js", "test/specs/basicAuth.spec.js", "test/specs/basicAuthWithPolyfill.spec.js", "test/specs/helpers/btoa.spec.js", "test/specs/requests.spec.js", "test/specs/utils/isX.spec.js"]
|
Dropping support for IE9
|
So this is a little self serving, but I think we should consider dropping support for IE9. The data is interesting. I'm seeing a [0.6% browser market share for IE9](https://netmarketshare.com/browser-market-share.aspx?options=%7B%22filter%22%3A%7B%22%24and%22%3A%5B%7B%22deviceType%22%3A%7B%22%24in%22%3A%5B%22Desktop%2Flaptop%22%5D%7D%7D%5D%7D%2C%22dateLabel%22%3A%22Trend%22%2C%22attributes%22%3A%22share%22%2C%22group%22%3A%22browserVersion%22%2C%22sort%22%3A%7B%22share%22%3A-1%7D%2C%22id%22%3A%22browsersDesktopVersions%22%2C%22dateInterval%22%3A%22Monthly%22%2C%22dateStart%22%3A%222017-07%22%2C%22dateEnd%22%3A%222018-06%22%2C%22segments%22%3A%22-1000%22%2C%22pageLength%22%3A50%7D).
What's neat about that data is that IE8 has twice the usage of IE9 ๐คทโโ๏ธ And IE10 has only 0.54% market share! I could make a reasonable argument for dropping both IE9 *and* IE10.
Of course, I'm only looking at this because I'd very much like to ship a new npm module with a few recently merged changes, and the IE9 tests are failing :)
What are folks thoughts? Does anyone feel strongly about the IE support matrix as it stands today?
@nickuraltsev @mzabriskie
|
https://github.com/axios/axios/issues/1656
|
https://github.com/axios/axios/pull/1689
|
33747ee8fb349a59368f62c9415664d53c84baf4
|
503418718f669fcc674719fd862b355605d7b41f
| 2018-07-06T06:15:49Z |
javascript
| 2018-08-06T07:56:51Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,643 |
["lib/adapters/xhr.js"]
|
Axios overwrite Content-Type when sending a blob/file with type.
|
Here is the error case: <https://codepen.io/Gerhut/pen/OErpQm?editors=0012>
Browsers will set Content-Type header automatically from `Blob#type` or `File#type` (if exists) when sending a Blob/File through xhr, which is overwritten by `axios.defaults.headers.post`.
Shall we provide a specific behavior about this case, either remove the `Content-Type` and let it be set by the browser (like FormData) or set it as `Blob#type` or `File#type` manually to increase compatibility? (Although I don't know if there is any browser don't set `Blob#type` or `File#type` in xhr.)
|
https://github.com/axios/axios/issues/1643
|
https://github.com/axios/axios/pull/1773
|
f2b478f7ffc4136334ceddf4e4cf9011c380f0bf
|
f3cc053fb9feda2c3d5a27513f16e6722a0f9737
| 2018-06-29T10:52:49Z |
javascript
| 2020-05-28T19:28:40Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,606 |
["README.md"]
|
get header in GET request with a specific name
|
<!-- Click "Preview" for a more readable version -->
#### Summary
Hello
i am using axios for a get request and in the response's header there is a key like this:
x-pagination-total-count
i tried to get the value of this key by 'result.headers.x-pagination-total-count' and the result is undefined for this line of code.
how should i get this header?
#### Context
- axios version: *e.g.: v0.16.0*
- Environment: *e.g.: node v6.9.4, chrome 54, windows 7*
|
https://github.com/axios/axios/issues/1606
|
https://github.com/axios/axios/pull/1901
|
b139abfc36d741b8a9075efed73e6df340175e9a
|
67e560da102916195cd06776d4090b1ec90426a6
| 2018-06-14T11:48:08Z |
javascript
| 2020-02-26T11:03:20Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,584 |
["lib/core/Axios.js", "lib/core/dispatchRequest.js", "lib/core/mergeConfig.js", "lib/utils.js", "test/specs/core/mergeConfig.spec.js", "test/specs/headers.spec.js", "test/specs/requests.spec.js", "test/specs/utils/deepMerge.spec.js", "test/specs/utils/isX.spec.js", "test/specs/utils/merge.spec.js"]
|
post data being over written with undefined when specified using axios.create
|
#### Summary
Expected: data defined when creating an instance will be written to the body when executing post/put/patch on a axios instance
actual: data is not being written to the body if only url is specified when executing post/put/patch
#### Details
If you define an instance using the following code:
```
var http = axios.create( {
baseURL: 'https://www.some-domain.com/',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
data: querystring.stringify( { 'form-field1' : 'value 1' } )
});
```
and then post using the following code (NOTE: do not provide any data param):
`http.post('/some/resource/');`
results in the data being over written with undefined due to the code that creates the post\put\patch methods (on line Axios.js:68):
```
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
/*eslint func-names:0*/
Axios.prototype[method] = function(url, data, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url,
data: data
}));
};
});
```
Changing this code to the following:
```
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
/*eslint func-names:0*/
Axios.prototype[method] = function(url, data, config) {
if(data)
return this.request(utils.merge(config || {}, {
method: method,
url: url,
data: data
}));
else
return this.request(utils.merge(config || {}, {
method: method,
url: url
}));
};
});
```
resolves the issue because now when line Axios.js:35, in the request(config) method, is executed:
```
config = utils.merge(defaults, {method: 'get'}, this.defaults, config);
```
config.data will no longer exist as an undefined value and so will no longer overwrite the data property on this.defaults ( what was created with the call to axios.create).
However, if the intent of line Axios.js:35 is to merge any existing data with new data there would still be a bug...
In the case where data is a string (e.g. application/x-www-form-urlencoded) then any data passed into the post\put\patch method on an axios instance will blow away any data passed into the create method rather then merging it.
#### Context
- axios version: 0.18.0
- Environment: node v8.10.0, windows 10
|
https://github.com/axios/axios/issues/1584
|
https://github.com/axios/axios/pull/2844
|
487941663b791a4a5273d456aab24c6ddd10eb0e
|
0d69a79c81a475f1cca6d83d824eed1e5b0b045d
| 2018-06-03T14:36:11Z |
javascript
| 2020-06-08T18:52:45Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,561 |
["lib/core/mergeConfig.js"]
|
charset latin1 not working
|
#### Summary
I can not make charset work. I am making request for a page that deals with `charset=iso-8859-1`, and even setting `{ charset: 'latin1' }`, correct decoding does not happen.
I'm following this https://github.com/axios/axios/pull/869
I've tried `latin1` and `latin-1`
```javascript
// url to open bases results
const url = `http://www.stf.jus.br/portal/jurisprudencia/listarJurisprudencia.asp?s1=%28SAUDE+COMPLEMENTAR%29&base=baseAcordaos&url=http://tinyurl.com/y9e68odp`
// request first page
axios.get(url, {}, { charset: 'latin-1' })
.then(({ data }) => {
console.log(data)
})
```
#### Context
- axios version: *v0.18.0*
- Environment: *node v10.1.0*
Thank you
|
https://github.com/axios/axios/issues/1561
|
https://github.com/axios/axios/pull/1745
|
2cf6ae460899d944553fbfd66800cdcb5cd871aa
|
17a967123cc1c06f15146a463b99816d4ca5f2b2
| 2018-05-24T22:59:31Z |
javascript
| 2020-02-15T13:49:26Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,451 |
["README.md"]
|
Some confusion in README: Config order of precedence
|
<!-- Click "Preview" for a more readable version -->
#### Summary
From the README:
```js
// Create an instance using the config defaults provided by the library
// At this point the timeout config value is `0` as is the default for the library
var instance = axios.create();
// Override timeout default for the library
// Now all requests will wait 2.5 seconds before timing out
instance.defaults.timeout = 2500;
// Override timeout for this request as it's known to take a long time
instance.get('/longRequest', {
timeout: 5000
});
```
Shouldn't that change the `timeout` only for that single created instance and not for all requests?
Probably this should read:
```
// Now all requests FOR THIS INSTANCE will wait 2.5 seconds before timing out
```
To change the `timeout` for ALL request I'd expect to have to do something like:
```js
axios.defaults.timeout = 2500;
```
Maybe the README is wrong...
|
https://github.com/axios/axios/issues/1451
|
https://github.com/axios/axios/pull/1456
|
9a6abd789f91a87d701116c0d86f1cfbc3295d66
|
e990a91c34bd81a5cb9261c7a0284dfd8169c0ae
| 2018-04-04T14:17:49Z |
javascript
| 2018-04-06T19:37:38Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,446 |
["lib/adapters/xhr.js", "test/specs/__helpers.js"]
|
Basic auth fails with non latin characters in username or password
|
#### Summary
The usage of btoa for basic auth prevents usage of non latin characters
Not really a big deal as you do not have to use the basic auth and can encode it yourself but thought I'd bring it up at least as passwords are becoming more unique.
https://github.com/axios/axios/blob/0499a970d7064d15c9361430b40729d9b8e6f6bb/lib/adapters/xhr.js#L42
To reproduce try using a password with basic auth that has a า symbol in it or by opening up a console and trying to use the btoa function on a string with a า symbol.
|
https://github.com/axios/axios/issues/1446
|
https://github.com/axios/axios/pull/1492
|
a98755c00a851765074e4ed866151232e03f931f
|
5effc0827e2134744d27529cb36970994768263b
| 2018-04-02T15:37:18Z |
javascript
| 2020-05-26T16:32:03Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,431 |
["README.md"]
|
explicit maxContentLength unit information missing
|
> // `maxContentLength` defines the max size of the http response content allowed
> maxContentLength: 2000,
Is it bytes we are talking here about?
|
https://github.com/axios/axios/issues/1431
|
https://github.com/axios/axios/pull/1463
|
ae1c2c30061f6c8d90c43cee3ea906f3151d0de8
|
7b11cc7181b4536233299efe98c6e7779d13e95e
| 2018-03-19T13:50:50Z |
javascript
| 2018-04-08T07:18:30Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,424 |
["lib/adapters/http.js", "test/unit/adapters/http.js"]
|
Request data stream errors are not captured with node.js
|
Greetings! When trying to set data in the request to a readable stream, it looks like stream errors aren't being captured and sent back through `reject`. Instead, it just throws.
Pretty simple repo here:
```js
const axios = require('axios');
const fs = require('fs');
axios.post('/to/here', {
data: fs.createReadStream('/it/dont/exist')
})
.then(console.log)
.catch(console.error)
```
Pretty sure the issue is here:
https://github.com/axios/axios/blob/master/lib/adapters/http.js#L236
The data gets piped without attaching an `.on('error')` handler to reject the promise.
|
https://github.com/axios/axios/issues/1424
|
https://github.com/axios/axios/pull/1425
|
e990a91c34bd81a5cb9261c7a0284dfd8169c0ae
|
cb630218303095c0075182b542ccb2f72d20dd9d
| 2018-03-16T04:20:02Z |
javascript
| 2018-04-06T19:38:04Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,415 |
["index.d.ts", "lib/core/enhanceError.js", "test/specs/core/createError.spec.js", "test/specs/core/enhanceError.spec.js"]
|
AxiosError type for javascript
|
#### Summary
Axios rejects error with Error type. Adding custom error type will help with distinguishing between axios and other errors. The only way now is to check 'request' field existence which is not always possible. Our internal custom error type has this field too.
#### Example:
``` js
const { axios, AxiosError } = require('axios');
...
try {
...
const response = await axios.get(url);
...
} catch (error) {
if(error instanceof AxiosError) {
return processAxiosError(error);
}
throw error;
}
```
#### Context
- axios version: 0.18.0
Relates to: #24
|
https://github.com/axios/axios/issues/1415
|
https://github.com/axios/axios/pull/1419
|
c0b40650d1c61d1e61c7853de806deeb3cb8ad12
|
b681e919c40fbf7abd109d0cb4f0caf2fd5553e5
| 2018-03-14T10:11:28Z |
javascript
| 2018-08-20T09:02:23Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,365 |
["index.d.ts", "test/typescript/axios.ts"]
|
`delete` TypeScript definition inconsistent with other HTTP method functions
|
#### Summary
Just started migrating to axios. I'm wondering why I can't define a type for the response body [for a `DELETE` request](https://github.com/axios/axios/blob/40b829994c2e407109a38a4cf82703261aa3c22c/index.d.ts#L113). The current typing (introduced in #1061) forces inconsistent syntax:
```ts
const { data: foo } = await axios.patch<Foo>(url, data)
// vs (pick your favourite)
const { data: foo } = await axios.delete(url) as AxiosResponse<Foo>
const { data: foo } = await (axios.delete(url) as AxiosPromise<Foo>)
const { data: foo }: AxiosResponse<Foo> = await axios.delete(url)
const foo = (await axios.delete(url)).data as Foo
```
Some consistency would be good here since both use cases appear to be supported equally.
**Additional thoughts**
Although this syntax is nice and terse (and I'm enjoying using it), it is listed in the ["common mistakes" section of DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes), which I assume are globally applicable rules for typing JS projects.
Specifically:
> If a type parameter does not appear in the types of any parameters, you don't really have a generic function, you just have a disguised type assertion.
The gist of which is that the server can really send back any old object, and there is no way to statically enforce it at TypeScript compile time. So the most "correct" type system to use (given this rule) would be for `data` to always be of type `any`, and force the user to explicitly cast using `as`.
eg.
Here the use of `as` indicates that a type assertion is being made, and that the code cannot be trusted:
```ts
async function getFoo(id: number) {
const { data } = await axios.get(fooPath(id))
return data as Foo
}
```
Or if you're really strict about it you can add runtime checks that are backed by the compiler:
```ts
function isFoo(o: any): o is Foo { /* ... */ }
async function getFoo(id: number) {
const { data } = await axios.get(fooPath(id))
if (!isFoo(data)) {
throw new TypeError("That ain't foo!")
}
// `data` is now of type `Foo`
return data
}
```
**cc** @d-fischer
#### Context
- axios version: v0.17.0
- Environment: TypeScript 2.7.1
|
https://github.com/axios/axios/issues/1365
|
https://github.com/axios/axios/pull/1401
|
0499a970d7064d15c9361430b40729d9b8e6f6bb
|
b14cdd842561b583b30b5bca5c209536c5cb8028
| 2018-02-15T06:18:04Z |
javascript
| 2018-03-08T15:56:53Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,345 |
["lib/core/Axios.js", "lib/core/dispatchRequest.js", "lib/core/mergeConfig.js", "lib/utils.js", "test/specs/core/mergeConfig.spec.js", "test/specs/headers.spec.js", "test/specs/requests.spec.js", "test/specs/utils/deepMerge.spec.js", "test/specs/utils/isX.spec.js", "test/specs/utils/merge.spec.js"]
|
Bug with transformResponse and transformRequest functions/arrays/objects
|
### Summary
tl;dr `utils.merge` break `transformResponse` and `transformRequest` behaviour in certain scenarios.
There are 3 parts of the problem.
#### Inconsistency between types in configs when setting `transform*` directly via `axiosInstance.defaults.transform*` and using `axios.create(config)`
The problem is that when setting directly one would set it as e.g. `axios.defaults.transformRequest = [f1, f2, f3]` but when passing the same _array_ via config it will get mergeda and become `{0: ฦ, 1: ฦ, 2: ฦ}`
```javascript
axios.create = function create (instanceConfig) {
return createInstance(utils.merge(defaults, instanceConfig))
}
```
and the `merge` function forces the array to become an `Object` with numbers converted to strings as keys.
That of course breaks a quite simple situation showed even in [examples/transform-response/index.html](https://github.com/axios/axios/blob/master/examples/transform-response/index.html)
```javascript
transformResponse: axios.defaults.transformResponse.concat(function (data, headers) {
```
Theoretically it still works as we can access this object via `[number]` but it seems as not quite expected behaviour.
Additionality when using typescript `transformResponse?: AxiosTransformer | AxiosTransformer[];` becomes very not true ;) and even can be a big problem when using a type guard `if (transformResponse instanceof Array) {`
#### Wrong behavior when merging `defaults` with per request `config`
Because of the merge method and the array becoming an Object we might encounter a totally unexpected behaviour when using `axios.get('url', { transformResponse: mySpecialOneTimeTransform });`
```
a = ['1', '2']
b = ['3']
utils.merge(a,b)
{0: "3", 1: "2"}
```
IMO that is the least expected behaviour when passing config to single request.
And that brings us to the last problem.
#### The _by design_ problem
1. When creating an axios instance - should the transforms be merged or overwritten.
2. When passing a config per request - should the transforms be merged or overwritten.
* merging - then there is no possibility to exceptionally not apply the default transforms [bad idea], also we should at least keep the order
* overwriting - that's kinda ok, we could then add a new transform by taking the defaults and `concat` a new transformer(as shown in example)
* adding new api methods to transform* for adding and removing functions (that's becoming weirdly similar to interceptors)
3. Do we really need to have `AxiosTransformer | AxiosTransformer[]` i suppose allowing only an array would be better. (That could be a breaking change, but probably acceptable as we are expecting release 1.0)
This issue is strongly connected with #1109 and might be connected with multiple defaults and config issues from the checklist in #1333.
Possibly quite a lot of this will be solved when checklist item `Substitute custom utils with lodash` is finished.
#### Context
- axios version: *e.g.: v0.17.1*
- Environment: *e.g.: node v8.9.3, windows 10*
|
https://github.com/axios/axios/issues/1345
|
https://github.com/axios/axios/pull/2844
|
487941663b791a4a5273d456aab24c6ddd10eb0e
|
0d69a79c81a475f1cca6d83d824eed1e5b0b045d
| 2018-02-07T21:07:30Z |
javascript
| 2020-06-08T18:52:45Z |
closed
|
axios/axios
|
https://github.com/axios/axios
| 1,309 |
["package-lock.json"]
|
Failed to load http://js.filatov-nikita.ru/api/products.php: Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers in preflight response.
|
I use laravel and vue with axios for sending request. And i get this error Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response. import Axios from 'axios';
Vue.prototype.$http = Axios.create({
baseURL: 'http://js.filatov-nikita.ru/api/',
crossDomain:true,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
|
https://github.com/axios/axios/issues/1309
|
https://github.com/axios/axios/pull/5294
|
3a7c363e540e388481346e0c0a3c80e8318dbf5d
|
e1989e91de13f2d6cd6732745ae64dbc41e288de
| 2018-01-21T13:55:44Z |
javascript
| 2022-11-22T17:56:32Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.