@zowe/db2-for-zowe-cli 6.1.17 → 6.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/lib/Db2PluginLifeCycle.d.ts +11 -9
- package/lib/Db2PluginLifeCycle.js +18 -13
- package/lib/Db2PluginLifeCycle.js.map +1 -1
- package/node_modules/adm-zip/adm-zip.js +32 -6
- package/node_modules/adm-zip/headers/entryHeader.js +13 -1
- package/node_modules/adm-zip/methods/inflater.js +33 -3
- package/node_modules/adm-zip/package.json +2 -2
- package/node_modules/adm-zip/util/errors.js +3 -0
- package/node_modules/adm-zip/util/utils.js +102 -14
- package/node_modules/adm-zip/zipEntry.js +43 -18
- package/node_modules/adm-zip/zipFile.js +10 -0
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +236 -73
- package/node_modules/axios/dist/axios.js +1308 -357
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +1443 -403
- package/node_modules/axios/dist/esm/axios.js +1443 -403
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +1483 -348
- package/node_modules/axios/index.d.cts +24 -1
- package/node_modules/axios/index.d.ts +22 -1
- package/node_modules/axios/lib/adapters/fetch.js +136 -30
- package/node_modules/axios/lib/adapters/http.js +277 -74
- package/node_modules/axios/lib/adapters/xhr.js +172 -16
- package/node_modules/axios/lib/core/Axios.js +87 -27
- package/node_modules/axios/lib/core/AxiosError.js +59 -0
- package/node_modules/axios/lib/core/AxiosHeaders.js +17 -4
- package/node_modules/axios/lib/core/InterceptorManager.js +118 -8
- package/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
- package/node_modules/axios/lib/core/buildFullPath.js +1 -13
- package/node_modules/axios/lib/core/createMultipartBody.js +37 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +28 -2
- package/node_modules/axios/lib/core/mergeConfig.js +183 -120
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/defaults/transitional.js +1 -0
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/AxiosTransformStream.js +11 -2
- package/node_modules/axios/lib/helpers/Http2Sessions.js +4 -1
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
- package/node_modules/axios/lib/helpers/composeSignals.js +6 -3
- package/node_modules/axios/lib/helpers/cookies.js +30 -6
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +34 -7
- package/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
- package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -1
- package/node_modules/axios/lib/helpers/fromDataURI.js +11 -4
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +4 -9
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +2 -1
- package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
- package/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
- package/node_modules/axios/lib/helpers/resolveConfig.js +20 -5
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +197 -6
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +14 -21
- package/node_modules/axios/lib/utils.js +192 -20
- package/node_modules/axios/package.json +1 -2
- package/node_modules/follow-redirects/README.md +27 -1
- package/node_modules/follow-redirects/index.js +11 -6
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/fs-extra/README.md +0 -1
- package/node_modules/fs-extra/lib/empty/index.js +4 -2
- package/node_modules/fs-extra/lib/util/stat.js +12 -2
- package/node_modules/fs-extra/package.json +1 -1
- package/node_modules/ibm_db/APIDocumentation.md +2883 -2024
- package/node_modules/ibm_db/LICENSE +23 -23
- package/node_modules/ibm_db/README.md +735 -735
- package/node_modules/ibm_db/binding.gyp +99 -98
- package/node_modules/ibm_db/installer/driverInstall.js +984 -958
- package/node_modules/ibm_db/installer/ifx.sh +38 -38
- package/node_modules/ibm_db/installer/setenv.sh +23 -23
- package/node_modules/ibm_db/installer/testODBCConnection.bat +51 -51
- package/node_modules/ibm_db/installer/testODBCConnection.sh +61 -61
- package/node_modules/ibm_db/lib/climacros.js +431 -431
- package/node_modules/ibm_db/lib/odbc.js +4293 -3487
- package/node_modules/ibm_db/lib/simple-queue.js +41 -41
- package/node_modules/ibm_db/package.json +70 -70
- package/node_modules/ibm_db/src/odbc.cpp +1495 -1396
- package/node_modules/ibm_db/src/odbc.h +477 -473
- package/node_modules/ibm_db/src/odbc_connection.cpp +1762 -1612
- package/node_modules/ibm_db/src/odbc_connection.h +228 -215
- package/node_modules/ibm_db/src/odbc_result.cpp +1547 -1547
- package/node_modules/ibm_db/src/odbc_result.h +152 -152
- package/node_modules/ibm_db/src/odbc_statement.cpp +2047 -861
- package/node_modules/ibm_db/src/odbc_statement.h +257 -135
- package/node_modules/ibm_db/src/strptime.c +389 -389
- package/node_modules/ibm_db/src/strptime.h +46 -46
- package/node_modules/ibm_db/test/README +23 -23
- package/node_modules/ibm_db/test/bench-insert.js +62 -62
- package/node_modules/ibm_db/test/bench-insertBatch10.js +74 -74
- package/node_modules/ibm_db/test/bench-insertBatch100.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch1000.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch10000.js +75 -75
- package/node_modules/ibm_db/test/bench-prepare-bind-execute-closeSync.js +60 -60
- package/node_modules/ibm_db/test/bench-prepare-bind-executeNonQuery.js +53 -53
- package/node_modules/ibm_db/test/bench-prepare-bindSync-execute-closeSync.js +50 -50
- package/node_modules/ibm_db/test/bench-prepare-bindSync-executeNonQuery.js +48 -48
- package/node_modules/ibm_db/test/bench-prepare-execute-closeSync.js +51 -51
- package/node_modules/ibm_db/test/bench-prepare-executeNonQuery.js +47 -47
- package/node_modules/ibm_db/test/bench-prepare-not.js +43 -43
- package/node_modules/ibm_db/test/bench-query-fetch.js +59 -59
- package/node_modules/ibm_db/test/bench-query-fetchAll.js +49 -49
- package/node_modules/ibm_db/test/bench-query-fetchAllSync.js +43 -43
- package/node_modules/ibm_db/test/bench-query.js +40 -40
- package/node_modules/ibm_db/test/bench-querySync-fetchArray.js +28 -28
- package/node_modules/ibm_db/test/bench-querySync.js +29 -29
- package/node_modules/ibm_db/test/common.d.ts +10 -10
- package/node_modules/ibm_db/test/common.js +127 -127
- package/node_modules/ibm_db/test/config.json +7 -7
- package/node_modules/ibm_db/test/config.zos.json +4 -4
- package/node_modules/ibm_db/test/data/sample1.txt +9 -9
- package/node_modules/ibm_db/test/data/trc.fmt +30114 -30114
- package/node_modules/ibm_db/test/nodeEE-leak-huge-query.js +152 -152
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-multiple-connections.js +148 -148
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-pool-connections.js +154 -154
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query.js +133 -133
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall-multiple-connections.js +174 -174
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall.js +169 -169
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query-multiple-connections.js +159 -159
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query.js +148 -148
- package/node_modules/ibm_db/test/odbc-bench.c +123 -123
- package/node_modules/ibm_db/test/perfTest.js +53 -53
- package/node_modules/ibm_db/test/quick-example.sh +30 -30
- package/node_modules/ibm_db/test/quick-example.ts +80 -80
- package/node_modules/ibm_db/test/run-bench.js +96 -96
- package/node_modules/ibm_db/test/run-nodeEE.js +132 -132
- package/node_modules/ibm_db/test/run-tests.js +132 -138
- package/node_modules/ibm_db/test/sql-cli.js +28 -28
- package/node_modules/ibm_db/test/test-all-data-types.js +109 -109
- package/node_modules/ibm_db/test/test-array-insert.js +178 -178
- package/node_modules/ibm_db/test/test-async-await.js +105 -105
- package/node_modules/ibm_db/test/test-attributes.js +34 -34
- package/node_modules/ibm_db/test/test-bad-pool-connection-prepare-execute.js +57 -57
- package/node_modules/ibm_db/test/test-basic-test.js +138 -138
- package/node_modules/ibm_db/test/test-binary-array-insert.js +73 -73
- package/node_modules/ibm_db/test/test-blob-from-file.js +90 -90
- package/node_modules/ibm_db/test/test-blob-insert.js +144 -144
- package/node_modules/ibm_db/test/test-blob-stream-insert.js +321 -299
- package/node_modules/ibm_db/test/test-blob-to-file.js +370 -370
- package/node_modules/ibm_db/test/test-block-fetch.js +364 -364
- package/node_modules/ibm_db/test/test-blocking-issue210.js +123 -123
- package/node_modules/ibm_db/test/test-call-async.js +64 -64
- package/node_modules/ibm_db/test/test-call-stmt.js +53 -53
- package/node_modules/ibm_db/test/test-cancel.js +703 -0
- package/node_modules/ibm_db/test/test-chinese-char.js +59 -59
- package/node_modules/ibm_db/test/test-connection.js +306 -0
- package/node_modules/ibm_db/test/test-date.js +32 -32
- package/node_modules/ibm_db/test/test-dbclob.js +93 -93
- package/node_modules/ibm_db/test/test-decimals.js +135 -135
- package/node_modules/ibm_db/test/test-describe-metadata.js +148 -0
- package/node_modules/ibm_db/test/test-executeFile.js +167 -167
- package/node_modules/ibm_db/test/test-executeFileSync.js +85 -85
- package/node_modules/ibm_db/test/test-fetch-apis.js +146 -146
- package/node_modules/ibm_db/test/test-fetchN.js +130 -130
- package/node_modules/ibm_db/test/test-getinfo.js +197 -197
- package/node_modules/ibm_db/test/test-ibm-db-issue14.js +58 -58
- package/node_modules/ibm_db/test/test-ibm-db-issue17.js +54 -54
- package/node_modules/ibm_db/test/test-ibm-db-issue18.js +54 -54
- package/node_modules/ibm_db/test/test-issue-1059-fetchAll-undefined.js +67 -67
- package/node_modules/ibm_db/test/test-issue-1080-array-blob-insert.js +40 -0
- package/node_modules/ibm_db/test/test-issue-54.js +39 -39
- package/node_modules/ibm_db/test/test-issue-get-column-value-2.js +44 -44
- package/node_modules/ibm_db/test/test-issue211.js +80 -80
- package/node_modules/ibm_db/test/test-issue253.js +39 -39
- package/node_modules/ibm_db/test/test-max-pool-size.js +96 -96
- package/node_modules/ibm_db/test/test-memory-leaks-new-objects.js +32 -32
- package/node_modules/ibm_db/test/test-multi-open-query-close.js +75 -75
- package/node_modules/ibm_db/test/test-param-put-data.js +713 -0
- package/node_modules/ibm_db/test/test-pool-idle-connection.js +72 -72
- package/node_modules/ibm_db/test/test-pool-operations.js +325 -0
- package/node_modules/ibm_db/test/test-pool-stale-connections.js +111 -111
- package/node_modules/ibm_db/test/test-pool-uncommited.js +33 -33
- package/node_modules/ibm_db/test/test-prepare-execute.js +339 -0
- package/node_modules/ibm_db/test/test-prepareSync-multiple-execution.js +93 -93
- package/node_modules/ibm_db/test/test-primary-foreign-keys.js +246 -0
- package/node_modules/ibm_db/test/test-procedures.js +243 -0
- package/node_modules/ibm_db/test/test-promise-all-data-types.js +42 -42
- package/node_modules/ibm_db/test/test-query-operations.js +405 -0
- package/node_modules/ibm_db/test/test-quick-example.js +25 -25
- package/node_modules/ibm_db/test/test-row-array-insert.js +167 -167
- package/node_modules/ibm_db/test/test-sp-array.js +54 -54
- package/node_modules/ibm_db/test/test-sp-dbc-6000.js +88 -88
- package/node_modules/ibm_db/test/test-sp-memleak.js +136 -136
- package/node_modules/ibm_db/test/test-sp-resultset-execute.js +269 -269
- package/node_modules/ibm_db/test/test-sp-resultset.js +228 -228
- package/node_modules/ibm_db/test/test-transactions.js +261 -0
- package/node_modules/ibm_db/test/test-typescript.js +48 -48
- package/node_modules/ibm_db/test/test-xml-datatype.js +70 -70
- package/node_modules/ibm_db/test/testWebApp.js +56 -56
- package/node_modules/ibm_db/test/trace +51 -51
- package/node_modules/ibm_db/test/typescript-apis-test.js +978 -978
- package/node_modules/ibm_db/test/webapp.html +17 -17
- package/node_modules/ibm_db/test/webapp.js +79 -79
- package/node_modules/ibm_db/typescript/README.md +28 -28
- package/node_modules/ibm_db/typescript/dist/Database.d.ts +26 -0
- package/node_modules/ibm_db/typescript/dist/ODBCStatement.d.ts +93 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/which-typed-array/CHANGELOG.md +14 -0
- package/node_modules/which-typed-array/README.md +0 -2
- package/node_modules/which-typed-array/index.d.ts +288 -11
- package/node_modules/which-typed-array/index.js +6 -7
- package/node_modules/which-typed-array/package.json +12 -11
- package/package.json +10 -11
- package/node_modules/ibm_db/test/disabled/test-binding-statement-rebinding.js +0 -59
- package/node_modules/ibm_db/test/disabled/test-open-dont-close.js +0 -12
- package/node_modules/ibm_db/test/disabled/test-param-select-with-booleans-only.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-decimals-only.js +0 -20
- package/node_modules/ibm_db/test/disabled/test-param-select-with-null.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-nulls-mixed.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-mixed.js +0 -22
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-only.js +0 -24
- package/node_modules/ibm_db/test/disabled/test-param-select-with-strings-only.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-closeSync.js +0 -62
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-error.js +0 -49
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-long-string.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-executeNonQuery.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-execute-closeSync.js +0 -46
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-executeNonQuery.js +0 -50
- package/node_modules/ibm_db/test/disabled/test-prepare.js +0 -34
- package/node_modules/ibm_db/test/disabled/test-prepareSync.js +0 -29
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAll.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAllSync.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-querySync-select-unicode.js +0 -20
- package/node_modules/ibm_db/test/test-affected-rows.js +0 -55
- package/node_modules/ibm_db/test/test-bad-connection-string.js +0 -30
- package/node_modules/ibm_db/test/test-binding-connection-timeOut.js +0 -31
- package/node_modules/ibm_db/test/test-binding-statement-executeSync.js +0 -84
- package/node_modules/ibm_db/test/test-binding-transaction-commit.js +0 -79
- package/node_modules/ibm_db/test/test-binding-transaction-commitSync.js +0 -53
- package/node_modules/ibm_db/test/test-closed.js +0 -14
- package/node_modules/ibm_db/test/test-connection-object.js +0 -16
- package/node_modules/ibm_db/test/test-describe-column.js +0 -92
- package/node_modules/ibm_db/test/test-describe-database.js +0 -18
- package/node_modules/ibm_db/test/test-describe-table.js +0 -31
- package/node_modules/ibm_db/test/test-domains-open.js +0 -19
- package/node_modules/ibm_db/test/test-global-open-close.js +0 -11
- package/node_modules/ibm_db/test/test-instantiate-one-and-end.js +0 -9
- package/node_modules/ibm_db/test/test-multi-open-close.js +0 -45
- package/node_modules/ibm_db/test/test-multi-openSync-closeSync.js +0 -52
- package/node_modules/ibm_db/test/test-open-close.js +0 -29
- package/node_modules/ibm_db/test/test-open-connectTimeout.js +0 -33
- package/node_modules/ibm_db/test/test-openSync.js +0 -31
- package/node_modules/ibm_db/test/test-pool-close.js +0 -120
- package/node_modules/ibm_db/test/test-pool-connect.js +0 -36
- package/node_modules/ibm_db/test/test-pool-rollbackTransaction.js +0 -35
- package/node_modules/ibm_db/test/test-prepareSync-bad-sql.js +0 -34
- package/node_modules/ibm_db/test/test-promise-open-close.js +0 -33
- package/node_modules/ibm_db/test/test-query-create-table-fetchSync.js +0 -23
- package/node_modules/ibm_db/test/test-query-create-table.js +0 -12
- package/node_modules/ibm_db/test/test-query-drop-table.js +0 -13
- package/node_modules/ibm_db/test/test-query-insert.js +0 -38
- package/node_modules/ibm_db/test/test-query-select-fetch.js +0 -21
- package/node_modules/ibm_db/test/test-query-select-fetchMode-array.js +0 -17
- package/node_modules/ibm_db/test/test-query-select.js +0 -64
- package/node_modules/ibm_db/test/test-queryResult.js +0 -35
- package/node_modules/ibm_db/test/test-queryStream.js +0 -43
- package/node_modules/ibm_db/test/test-querySync-select-with-exception.js +0 -25
- package/node_modules/ibm_db/test/test-querySync-select.js +0 -28
- package/node_modules/ibm_db/test/test-require-and-end.js +0 -8
- package/node_modules/ibm_db/test/test-statement-close.js +0 -118
- package/node_modules/ibm_db/test/test-transaction-commit-sync.js +0 -54
- package/node_modules/ibm_db/test/test-transaction-commit.js +0 -79
- package/node_modules/which-typed-array/eslint.config.mjs +0 -12
- package/node_modules/which-typed-array/test/index.js +0 -105
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/LICENSE +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/README.md +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/chownr.js +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/package.json +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/.travis.yml +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/LICENSE +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/README.md +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/lib/string_decoder.js +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/package.json +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
> [!IMPORTANT]
|
|
2
|
+
> [**Get Security Updates for Axios v0 →**](https://www.herodevs.com/support/nes-for-axios?utm_source=axios-site&utm_medium=referral&utm_campaign=nes-for-axios_global&utm_content=landing-page_none_20260924_a)
|
|
3
|
+
|
|
1
4
|
<h3 align="center">💎 Platinum sponsors <br /></h3>
|
|
2
5
|
<table align="center">
|
|
3
6
|
<tr>
|
|
@@ -139,32 +142,6 @@
|
|
|
139
142
|
</td>
|
|
140
143
|
</tr>
|
|
141
144
|
<tr width="33.333333333333336%">
|
|
142
|
-
<td align="center" width="33.333333333333336%">
|
|
143
|
-
<a
|
|
144
|
-
href="https://stytch.com/"
|
|
145
|
-
style="padding: 10px; display: inline-block"
|
|
146
|
-
target="_blank"
|
|
147
|
-
>
|
|
148
|
-
<img
|
|
149
|
-
width="90px"
|
|
150
|
-
height="90px"
|
|
151
|
-
src="https://images.opencollective.com/stytch/f84ce43/logo/256.png?height=256"
|
|
152
|
-
alt="Stytch"
|
|
153
|
-
/>
|
|
154
|
-
</a>
|
|
155
|
-
<p
|
|
156
|
-
align="center"
|
|
157
|
-
>
|
|
158
|
-
The identity platform for humans & AI agents
|
|
159
|
-
</p>
|
|
160
|
-
<p align="center">
|
|
161
|
-
<a
|
|
162
|
-
href="https://stytch.com"
|
|
163
|
-
target="_blank"
|
|
164
|
-
><b>stytch.com</b></a
|
|
165
|
-
>
|
|
166
|
-
</p>
|
|
167
|
-
</td>
|
|
168
145
|
<td align="center" width="33.333333333333336%">
|
|
169
146
|
<a
|
|
170
147
|
href="https://rxdb.info/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship&utm_content=logo"
|
|
@@ -215,146 +192,165 @@
|
|
|
215
192
|
>
|
|
216
193
|
</p>
|
|
217
194
|
</td>
|
|
218
|
-
</tr>
|
|
219
|
-
<tr width="33.333333333333336%">
|
|
220
195
|
<td align="center" width="33.333333333333336%">
|
|
221
196
|
<a
|
|
222
|
-
href="https://
|
|
197
|
+
href="https://global.fun88.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
223
198
|
style="padding: 10px; display: inline-block"
|
|
224
199
|
target="_blank"
|
|
225
200
|
>
|
|
226
201
|
<img
|
|
227
202
|
width="71px"
|
|
228
203
|
height="70px"
|
|
229
|
-
src="https://images.opencollective.com/
|
|
230
|
-
alt="
|
|
204
|
+
src="https://images.opencollective.com/fun88-official/bf2843c/logo.png"
|
|
205
|
+
alt="Fun 88"
|
|
231
206
|
/>
|
|
232
207
|
</a>
|
|
233
208
|
<p
|
|
234
209
|
align="center"
|
|
235
210
|
>
|
|
236
|
-
|
|
211
|
+
Fun88 is a global online gambling and betting brand founded in 2009, offering a wide range of services including sports betting, live casino games, slots, and virtual gaming.
|
|
237
212
|
</p>
|
|
238
213
|
<p align="center">
|
|
239
214
|
<a
|
|
240
|
-
href="https://
|
|
215
|
+
href="https://global.fun88.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
241
216
|
target="_blank"
|
|
242
|
-
><b>
|
|
217
|
+
><b>global.fun88.com</b></a
|
|
243
218
|
>
|
|
244
219
|
</p>
|
|
245
220
|
</td>
|
|
221
|
+
</tr>
|
|
222
|
+
<tr width="33.333333333333336%">
|
|
246
223
|
<td align="center" width="33.333333333333336%">
|
|
247
224
|
<a
|
|
248
|
-
href="https://
|
|
225
|
+
href="https://www.jbo88b.com/vn/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
249
226
|
style="padding: 10px; display: inline-block"
|
|
250
227
|
target="_blank"
|
|
251
228
|
>
|
|
252
229
|
<img
|
|
253
230
|
width="71px"
|
|
254
231
|
height="70px"
|
|
255
|
-
src="https://images.opencollective.com/
|
|
256
|
-
alt="
|
|
232
|
+
src="https://images.opencollective.com/jbo-vietnam/3fc6159/avatar.png"
|
|
233
|
+
alt="JBO Vietnam"
|
|
257
234
|
/>
|
|
258
235
|
</a>
|
|
259
236
|
<p
|
|
260
237
|
align="center"
|
|
261
238
|
>
|
|
262
|
-
|
|
239
|
+
JBO Vietnam is a prominent online entertainment brand in Vietnam, offering sports betting, esports, online casino games, and a wide range of other exciting games.
|
|
263
240
|
</p>
|
|
264
241
|
<p align="center">
|
|
265
242
|
<a
|
|
266
|
-
href="https://
|
|
243
|
+
href="https://www.jbo88b.com/vn/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
267
244
|
target="_blank"
|
|
268
|
-
><b>
|
|
245
|
+
><b>jbo88b.com</b></a
|
|
269
246
|
>
|
|
270
247
|
</p>
|
|
271
248
|
</td>
|
|
272
249
|
<td align="center" width="33.333333333333336%">
|
|
273
250
|
<a
|
|
274
|
-
href="https://
|
|
251
|
+
href="https://www.jbo579.com/th/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
275
252
|
style="padding: 10px; display: inline-block"
|
|
276
253
|
target="_blank"
|
|
277
254
|
>
|
|
278
255
|
<img
|
|
279
256
|
width="71px"
|
|
280
257
|
height="70px"
|
|
281
|
-
src="https://images.opencollective.com/
|
|
282
|
-
alt="
|
|
258
|
+
src="https://images.opencollective.com/jbo-thailand/d17e84f/avatar.png"
|
|
259
|
+
alt="JBO Thailand"
|
|
283
260
|
/>
|
|
284
261
|
</a>
|
|
285
262
|
<p
|
|
286
263
|
align="center"
|
|
287
264
|
>
|
|
288
|
-
|
|
265
|
+
JBO Thailand is a prominent online entertainment brand in Thailand, offering sports betting, esports, online casino games, and a wide range of other exciting games.
|
|
289
266
|
</p>
|
|
290
267
|
<p align="center">
|
|
291
268
|
<a
|
|
292
|
-
href="https://
|
|
269
|
+
href="https://www.jbo579.com/th/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
293
270
|
target="_blank"
|
|
294
|
-
><b>
|
|
271
|
+
><b>jbo88b.com</b></a
|
|
295
272
|
>
|
|
296
273
|
</p>
|
|
297
274
|
</td>
|
|
298
|
-
</tr>
|
|
299
|
-
<tr width="33.333333333333336%">
|
|
300
275
|
<td align="center" width="33.333333333333336%">
|
|
301
276
|
<a
|
|
302
|
-
href="https://www.
|
|
277
|
+
href="https://www.scrapingbee.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
303
278
|
style="padding: 10px; display: inline-block"
|
|
304
279
|
target="_blank"
|
|
305
280
|
>
|
|
306
281
|
<img
|
|
307
|
-
width="
|
|
308
|
-
height="
|
|
309
|
-
src="https://images.opencollective.com/
|
|
310
|
-
alt="
|
|
282
|
+
width="90px"
|
|
283
|
+
height="90px"
|
|
284
|
+
src="https://images.opencollective.com/scrapingbee/6d5dc95/logo.png"
|
|
285
|
+
alt="ScrapingBee"
|
|
311
286
|
/>
|
|
312
287
|
</a>
|
|
313
288
|
<p
|
|
314
289
|
align="center"
|
|
315
290
|
>
|
|
316
|
-
|
|
291
|
+
Scrape websites with a powerful web scraping API without managing proxies, browsers, or anti-bot defenses.
|
|
317
292
|
</p>
|
|
318
293
|
<p align="center">
|
|
319
294
|
<a
|
|
320
|
-
href="https://www.
|
|
295
|
+
href="https://www.scrapingbee.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
321
296
|
target="_blank"
|
|
322
|
-
><b>
|
|
297
|
+
><b>scrapingbee.com</b></a
|
|
323
298
|
>
|
|
324
299
|
</p>
|
|
325
300
|
</td>
|
|
301
|
+
</tr>
|
|
302
|
+
<tr width="33.333333333333336%">
|
|
326
303
|
<td align="center" width="33.333333333333336%">
|
|
327
304
|
<a
|
|
328
|
-
href="https://www.
|
|
305
|
+
href="https://www.herodevs.com/support/nes-for-axios?utm_source=axios-site&utm_medium=referral&utm_campaign=nes-for-axios_global&utm_content=landing-page_none_20260924_a"
|
|
329
306
|
style="padding: 10px; display: inline-block"
|
|
330
307
|
target="_blank"
|
|
331
308
|
>
|
|
332
309
|
<img
|
|
333
|
-
width="
|
|
334
|
-
height="
|
|
335
|
-
src="https://
|
|
336
|
-
alt="
|
|
310
|
+
width="180px"
|
|
311
|
+
height="53px"
|
|
312
|
+
src="https://axios.rest/sponsors/herodevs.svg"
|
|
313
|
+
alt="HeroDevs"
|
|
337
314
|
/>
|
|
338
315
|
</a>
|
|
339
316
|
<p
|
|
340
317
|
align="center"
|
|
341
318
|
>
|
|
342
|
-
|
|
319
|
+
Security and long-term support for end-of-life open source software.
|
|
343
320
|
</p>
|
|
344
321
|
<p align="center">
|
|
345
322
|
<a
|
|
346
|
-
href="https://www.
|
|
323
|
+
href="https://www.herodevs.com/support/nes-for-axios?utm_source=axios-site&utm_medium=referral&utm_campaign=nes-for-axios_global&utm_content=landing-page_none_20260924_a"
|
|
347
324
|
target="_blank"
|
|
348
|
-
><b>
|
|
325
|
+
><b>herodevs.com</b></a
|
|
349
326
|
>
|
|
350
327
|
</p>
|
|
351
328
|
</td>
|
|
352
329
|
<td align="center" width="33.333333333333336%">
|
|
353
330
|
<a
|
|
354
|
-
href="https://opencollective.com/
|
|
331
|
+
href="https://opencollective.com/sweepico-promo-code"
|
|
332
|
+
style="padding: 10px; display: inline-block"
|
|
355
333
|
target="_blank"
|
|
356
|
-
>💜 Become a sponsor</a
|
|
357
334
|
>
|
|
335
|
+
<img
|
|
336
|
+
width="90px"
|
|
337
|
+
height="90px"
|
|
338
|
+
src="https://images.opencollective.com/sweepico-promo-code/4dd517a/logo.png"
|
|
339
|
+
alt="Sweepico Promo Code"
|
|
340
|
+
/>
|
|
341
|
+
</a>
|
|
342
|
+
<p
|
|
343
|
+
align="center"
|
|
344
|
+
>
|
|
345
|
+
Social Gaming Platform
|
|
346
|
+
</p>
|
|
347
|
+
<p align="center">
|
|
348
|
+
<a
|
|
349
|
+
href="https://opencollective.com/sweepico-promo-code"
|
|
350
|
+
target="_blank"
|
|
351
|
+
><b>Sweepico Promo Code</b></a
|
|
352
|
+
>
|
|
353
|
+
</p>
|
|
358
354
|
</td>
|
|
359
355
|
</tr>
|
|
360
356
|
</table>
|
|
@@ -536,13 +532,13 @@ const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundl
|
|
|
536
532
|
Using jsDelivr CDN (ES5 UMD browser module):
|
|
537
533
|
|
|
538
534
|
```html
|
|
539
|
-
<script src="https://cdn.jsdelivr.net/npm/axios@1.
|
|
535
|
+
<script src="https://cdn.jsdelivr.net/npm/axios@1.20.0/dist/axios.min.js"></script>
|
|
540
536
|
```
|
|
541
537
|
|
|
542
538
|
Using unpkg CDN:
|
|
543
539
|
|
|
544
540
|
```html
|
|
545
|
-
<script src="https://unpkg.com/axios@1.
|
|
541
|
+
<script src="https://unpkg.com/axios@1.20.0/dist/axios.min.js"></script>
|
|
546
542
|
```
|
|
547
543
|
|
|
548
544
|
## Example
|
|
@@ -648,6 +644,7 @@ axios({
|
|
|
648
644
|
|
|
649
645
|
```js
|
|
650
646
|
// GET request for remote image in node.js
|
|
647
|
+
import fs from 'fs';
|
|
651
648
|
const response = await axios({
|
|
652
649
|
method: 'get',
|
|
653
650
|
url: 'https://bit.ly/2mTM3nY',
|
|
@@ -763,6 +760,8 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
763
760
|
// `baseURL` is not a security boundary. If `url` is attacker-controlled, validate it
|
|
764
761
|
// before passing it to axios. Relative URLs can contain `..` segments that resolve
|
|
765
762
|
// outside an intended path prefix after the final URL is parsed.
|
|
763
|
+
// HTTP(S) URLs must include `//` after the protocol. Values such as
|
|
764
|
+
// `https:example.com` and `https:/example.com` are rejected with ERR_INVALID_URL.
|
|
766
765
|
baseURL: 'https://some-domain.com/api/',
|
|
767
766
|
|
|
768
767
|
// `allowAbsoluteUrls` determines whether or not absolute URLs will override a configured `baseUrl`.
|
|
@@ -1371,6 +1370,40 @@ axios.interceptors.request.use(
|
|
|
1371
1370
|
);
|
|
1372
1371
|
```
|
|
1373
1372
|
|
|
1373
|
+
If a synchronous request interceptor throws, Axios calls that interceptor's paired rejection handler and stops running the remaining request interceptors. A rejection handler that returns normally, including one that returns `undefined` or a fulfilled Promise, treats the error as handled: Axios dispatches the request with the last valid config, and ignores the handler's return value. To block dispatch, omit the rejection handler or throw/return a rejected Promise from it. The final error then continues through response rejection interceptors.
|
|
1374
|
+
|
|
1375
|
+
Use a rejected Promise when validation must prevent the request:
|
|
1376
|
+
|
|
1377
|
+
```js
|
|
1378
|
+
axios.interceptors.request.use(
|
|
1379
|
+
function validate(config) {
|
|
1380
|
+
if (!config.headers.has('Authorization')) {
|
|
1381
|
+
throw new Error('Authorization is required');
|
|
1382
|
+
}
|
|
1383
|
+
return config;
|
|
1384
|
+
},
|
|
1385
|
+
function rejectInvalidRequest(error) {
|
|
1386
|
+
return Promise.reject(error);
|
|
1387
|
+
},
|
|
1388
|
+
{ synchronous: true }
|
|
1389
|
+
);
|
|
1390
|
+
```
|
|
1391
|
+
|
|
1392
|
+
A logging-only rejection handler can return normally to preserve the existing request-continuation behavior:
|
|
1393
|
+
|
|
1394
|
+
```js
|
|
1395
|
+
axios.interceptors.request.use(
|
|
1396
|
+
function prepare(config) {
|
|
1397
|
+
throw new Error('Optional preparation failed');
|
|
1398
|
+
},
|
|
1399
|
+
function logPreparationFailure(error) {
|
|
1400
|
+
console.warn(error);
|
|
1401
|
+
// Returning normally dispatches with the last valid config.
|
|
1402
|
+
},
|
|
1403
|
+
{ synchronous: true }
|
|
1404
|
+
);
|
|
1405
|
+
```
|
|
1406
|
+
|
|
1374
1407
|
If you want to execute a particular interceptor based on a runtime check,
|
|
1375
1408
|
you can add a `runWhen` function to the options object. The request interceptor will not run **if and only if** the return
|
|
1376
1409
|
of `runWhen` is `false`. Axios calls the function with the config
|
|
@@ -1438,7 +1471,7 @@ When a response is fulfilled and multiple response interceptors are registered:
|
|
|
1438
1471
|
- If a fulfillment interceptor throws, Axios skips the next fulfillment interceptor and calls the next rejection interceptor.
|
|
1439
1472
|
- After the error is caught, later fulfillment interceptors run again, just like in a promise chain.
|
|
1440
1473
|
|
|
1441
|
-
Read [the interceptor tests](./
|
|
1474
|
+
Read [the interceptor tests](./tests/browser/interceptors.browser.test.js) to see all this in code.
|
|
1442
1475
|
|
|
1443
1476
|
## Error types
|
|
1444
1477
|
|
|
@@ -1496,6 +1529,10 @@ axios.get('/user/12345').catch(function (error) {
|
|
|
1496
1529
|
});
|
|
1497
1530
|
```
|
|
1498
1531
|
|
|
1532
|
+
Axios rejects an `http:` or `https:` request `url` or `baseURL` that omits `//` after the protocol. For example, `https:example.com` and `https:/example.com` reject with `AxiosError` code `ERR_INVALID_URL` instead of being silently normalized. Pass a well-formed URL such as `https://example.com`.
|
|
1533
|
+
|
|
1534
|
+
The error identifies the malformed URL, for example `Invalid URL "https:example.com": missing "//" after protocol`. To keep logs useful without leaking secrets, Axios reports the control-character-normalized URL with credentials, query parameter values, and fragment contents redacted; the scheme, host, path, and query parameter names remain visible.
|
|
1535
|
+
|
|
1499
1536
|
Use `validateStatus` to override the default condition (`status >= 200 && status < 300`) and choose which HTTP status codes should reject.
|
|
1500
1537
|
|
|
1501
1538
|
```js
|
|
@@ -1931,6 +1968,24 @@ formData.append('users[1][surname]', 'Anderson');
|
|
|
1931
1968
|
formData.append('obj2{}', '[{"x":1}]');
|
|
1932
1969
|
```
|
|
1933
1970
|
|
|
1971
|
+
### Converting FormData to JSON
|
|
1972
|
+
|
|
1973
|
+
`axios.formToJSON()` converts `FormData` field names that use dot or bracket notation into nested objects and arrays. Only `.`, `[`, and `]` are structural separators. Other characters, including `-`, spaces, `+`, `*`, and `&`, remain part of the literal key.
|
|
1974
|
+
|
|
1975
|
+
```js
|
|
1976
|
+
const form = new FormData();
|
|
1977
|
+
form.append('user-name', 'johndoe');
|
|
1978
|
+
form.append('user.name', 'john');
|
|
1979
|
+
|
|
1980
|
+
console.log(axios.formToJSON(form));
|
|
1981
|
+
// {
|
|
1982
|
+
// 'user-name': 'johndoe',
|
|
1983
|
+
// user: { name: 'john' }
|
|
1984
|
+
// }
|
|
1985
|
+
```
|
|
1986
|
+
|
|
1987
|
+
`user[name]` also creates `{ user: { name: ... } }`, while `items[]` creates an array.
|
|
1988
|
+
|
|
1934
1989
|
Axios supports `postForm`, `putForm`, and `patchForm` as shortcuts for the matching HTTP methods with the `Content-Type` header preset to `multipart/form-data`.
|
|
1935
1990
|
|
|
1936
1991
|
## Posting files
|
|
@@ -2004,10 +2059,9 @@ submits this JSON object:
|
|
|
2004
2059
|
{
|
|
2005
2060
|
"foo": "1",
|
|
2006
2061
|
"deep": {
|
|
2007
|
-
"prop":
|
|
2008
|
-
"spaced": "3"
|
|
2009
|
-
}
|
|
2062
|
+
"prop": "2"
|
|
2010
2063
|
},
|
|
2064
|
+
"deep prop spaced": "3",
|
|
2011
2065
|
"baz": [
|
|
2012
2066
|
"4",
|
|
2013
2067
|
"5"
|
|
@@ -2018,6 +2072,8 @@ submits this JSON object:
|
|
|
2018
2072
|
}
|
|
2019
2073
|
```
|
|
2020
2074
|
|
|
2075
|
+
Only dot and bracket notation create nested paths when a form is converted to JSON. Spaces and other punctuation remain part of literal field names.
|
|
2076
|
+
|
|
2021
2077
|
Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported.
|
|
2022
2078
|
|
|
2023
2079
|
## Progress capturing
|
|
@@ -2246,8 +2302,9 @@ Returns `this`.
|
|
|
2246
2302
|
### AxiosHeaders#get(header)
|
|
2247
2303
|
|
|
2248
2304
|
```
|
|
2249
|
-
get(headerName: string,
|
|
2305
|
+
get(headerName: string, parser: typeof AxiosHeaders.parseParameters): AxiosHeaderParameters;
|
|
2250
2306
|
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
|
2307
|
+
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
|
|
2251
2308
|
```
|
|
2252
2309
|
|
|
2253
2310
|
Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`,
|
|
@@ -2267,6 +2324,15 @@ console.log(headers.get('Content-Type', true)); // parse key-value pairs from a
|
|
|
2267
2324
|
// boundary: 'Asrf456BGe4h'
|
|
2268
2325
|
// }
|
|
2269
2326
|
|
|
2327
|
+
const quotedHeaders = new AxiosHeaders({
|
|
2328
|
+
'Content-Type': 'multipart/form-data; boundary="a,b"',
|
|
2329
|
+
});
|
|
2330
|
+
|
|
2331
|
+
console.log({
|
|
2332
|
+
...quotedHeaders.get('Content-Type', AxiosHeaders.parseParameters),
|
|
2333
|
+
});
|
|
2334
|
+
// { boundary: 'a,b' }
|
|
2335
|
+
|
|
2270
2336
|
console.log(
|
|
2271
2337
|
headers.get('Content-Type', (value, name, headers) => {
|
|
2272
2338
|
return String(value).replace(/a/g, 'ZZZ');
|
|
@@ -2278,6 +2344,10 @@ console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]);
|
|
|
2278
2344
|
// boundary=Asrf456BGe4h
|
|
2279
2345
|
```
|
|
2280
2346
|
|
|
2347
|
+
`AxiosHeaders.parseParameters` is the opt-in parser for normalized HTTP parameter values. It returns a null-prototype map, matches parameter names case-insensitively, removes quoted-string delimiters, decodes escaped quotes and backslashes, preserves commas and semicolons inside quoted values, and removes only HTTP optional whitespace around unquoted values. It omits the unsafe keys `__proto__`, `constructor`, and `prototype`.
|
|
2348
|
+
|
|
2349
|
+
Passing `true` remains the legacy tokenizer and keeps its existing output for backward compatibility.
|
|
2350
|
+
|
|
2281
2351
|
Returns the value of the header.
|
|
2282
2352
|
|
|
2283
2353
|
### AxiosHeaders#has(header, matcher?)
|
|
@@ -2562,6 +2632,99 @@ try {
|
|
|
2562
2632
|
}
|
|
2563
2633
|
```
|
|
2564
2634
|
|
|
2635
|
+
### Typing request data and query params
|
|
2636
|
+
|
|
2637
|
+
`AxiosRequestConfig<D = any, P = any>` uses `D` for the request body and `P` for query parameters. The params serializer receives the same `P`, and both types are preserved on the default response config:
|
|
2638
|
+
|
|
2639
|
+
```typescript
|
|
2640
|
+
import axios, {
|
|
2641
|
+
type AxiosPromise,
|
|
2642
|
+
type AxiosRequestConfig,
|
|
2643
|
+
type InternalAxiosRequestConfig,
|
|
2644
|
+
} from 'axios';
|
|
2645
|
+
|
|
2646
|
+
interface RequestBody {
|
|
2647
|
+
includeArchived: boolean;
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
interface SearchParams {
|
|
2651
|
+
query: string;
|
|
2652
|
+
page?: number;
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
interface SearchResponse {
|
|
2656
|
+
results: string[];
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
const config: AxiosRequestConfig<RequestBody, SearchParams> = {
|
|
2660
|
+
data: { includeArchived: false },
|
|
2661
|
+
params: { query: 'axios', page: 1 },
|
|
2662
|
+
paramsSerializer: (params) => `${params.query}:${params.page ?? 1}`,
|
|
2663
|
+
};
|
|
2664
|
+
|
|
2665
|
+
const response = await axios.get('/search', config);
|
|
2666
|
+
response.config.data; // RequestBody | undefined
|
|
2667
|
+
response.config.params; // SearchParams | undefined
|
|
2668
|
+
|
|
2669
|
+
const invalidConfig: AxiosRequestConfig<RequestBody, SearchParams> = {
|
|
2670
|
+
// @ts-expect-error `query` must be a string
|
|
2671
|
+
params: { query: 123 },
|
|
2672
|
+
};
|
|
2673
|
+
|
|
2674
|
+
const adapter = (
|
|
2675
|
+
adapterConfig: InternalAxiosRequestConfig<RequestBody, SearchParams>
|
|
2676
|
+
): AxiosPromise<SearchResponse, RequestBody, SearchParams> =>
|
|
2677
|
+
Promise.resolve({
|
|
2678
|
+
data: { results: [] },
|
|
2679
|
+
status: 200,
|
|
2680
|
+
statusText: 'OK',
|
|
2681
|
+
headers: {},
|
|
2682
|
+
config: adapterConfig,
|
|
2683
|
+
});
|
|
2684
|
+
```
|
|
2685
|
+
|
|
2686
|
+
The request methods place `P` last—`<T, R, D, P>`—so the existing response data (`T`), custom response (`R`), and request data (`D`) positions do not change. Explicit custom response types still determine the resolved value. `RawAxiosRequestConfig`, `InternalAxiosRequestConfig`, defaults, `AxiosResponse`, `AxiosPromise<T, D, P>`, `AxiosError`, `CanceledError`, callable instances, adapters, and `mergeConfig()` also carry `P`. The default is `any` for backward compatibility.
|
|
2687
|
+
|
|
2688
|
+
Use all three public error generics when cancellation narrowing must retain the response, request body, and params types:
|
|
2689
|
+
|
|
2690
|
+
```typescript
|
|
2691
|
+
declare const error: unknown;
|
|
2692
|
+
|
|
2693
|
+
if (axios.isCancel<SearchResponse, RequestBody, SearchParams>(error)) {
|
|
2694
|
+
error.config?.data; // RequestBody | undefined
|
|
2695
|
+
error.config?.params; // SearchParams | undefined
|
|
2696
|
+
}
|
|
2697
|
+
```
|
|
2698
|
+
|
|
2699
|
+
### Symbol-keyed custom request config
|
|
2700
|
+
|
|
2701
|
+
Own enumerable symbol properties survive config merging, so module-augmented options can reach request interceptors and adapters:
|
|
2702
|
+
|
|
2703
|
+
```typescript
|
|
2704
|
+
import axios from 'axios';
|
|
2705
|
+
|
|
2706
|
+
export const someFlag: unique symbol = Symbol(
|
|
2707
|
+
'some flag used in request interceptor'
|
|
2708
|
+
);
|
|
2709
|
+
|
|
2710
|
+
declare module 'axios' {
|
|
2711
|
+
interface AxiosRequestConfig<D = any, P = any> {
|
|
2712
|
+
[someFlag]?: boolean;
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
axios.interceptors.request.use((config) => {
|
|
2717
|
+
if (config[someFlag]) {
|
|
2718
|
+
config.headers.set('X-Some-Flag', 'enabled');
|
|
2719
|
+
}
|
|
2720
|
+
return config;
|
|
2721
|
+
});
|
|
2722
|
+
|
|
2723
|
+
await axios.get('/users', { [someFlag]: true });
|
|
2724
|
+
```
|
|
2725
|
+
|
|
2726
|
+
Only own enumerable symbol properties are copied; inherited and non-enumerable symbol properties are not.
|
|
2727
|
+
|
|
2565
2728
|
Because axios publishes an ESM default export and a CJS `module.exports`, TypeScript has a few caveats.
|
|
2566
2729
|
The recommended setting is `"moduleResolution": "node16"`, which is implied by `"module": "node16"`. This requires TypeScript 4.7 or greater.
|
|
2567
2730
|
If you use ESM, your settings should be fine.
|