@openclaw/slack 2026.7.2-beta.4 → 2026.7.2-beta.5

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.
Files changed (607) hide show
  1. package/README.md +1 -1
  2. package/dist/{action-runtime-CFU52n4W.js → action-runtime-BO3HK_50.js} +5 -5
  3. package/dist/action-runtime.runtime-DbEcqEXC.js +2 -0
  4. package/dist/{actions-D51foiwR.js → actions-BkOaiDSX.js} +4 -4
  5. package/dist/{actions.runtime-BMJwtf5C.js → actions.runtime-Do-iOL51.js} +1 -1
  6. package/dist/api.js +12 -13
  7. package/dist/{approval-handler.runtime-3b4-wxMl.js → approval-handler.runtime-BAnGN7w0.js} +2 -2
  8. package/dist/{channel-Ds8NKvfr.js → channel-Cnrlie9S.js} +20 -32
  9. package/dist/channel-config-api.js +1 -1
  10. package/dist/channel-plugin-api.js +1 -1
  11. package/dist/{channel-type-DXkUajFP.js → channel-type-CPDX8EV-.js} +3 -3
  12. package/dist/{channel.setup-DOSTEDfA.js → channel.setup-DyZdLwUB.js} +4 -24
  13. package/dist/{setup-core-tPxMuFez.js → config-adapter-Bb8hn2tM.js} +38 -67
  14. package/dist/{config-schema-B4j4tCOI.js → config-schema-BajbuJGL.js} +0 -6
  15. package/dist/{directory-config-B08pm5ZT.js → directory-config-CeixfVuC.js} +1 -1
  16. package/dist/directory-contract-api.js +1 -1
  17. package/dist/{directory-live-DpPKzPrn.js → directory-live-CUwGPX2d.js} +2 -2
  18. package/dist/doctor-contract-CsGH1Dfc.js +158 -0
  19. package/dist/doctor-contract-api.js +1 -1
  20. package/dist/{group-policy-CdnQzQBI.js → group-policy-CthIXE2T.js} +27 -13
  21. package/dist/{message-tool-api-ByVyIVOh.js → message-tool-api-CvKoWYYQ.js} +0 -5
  22. package/dist/message-tool-api.js +1 -1
  23. package/dist/{monitor-CnB_WKvF.js → monitor-Cb5ZsOTY.js} +4 -4
  24. package/dist/{outbound-adapter-DuPz2HHt.js → outbound-adapter-sGrozuRg.js} +11 -68
  25. package/dist/{pipeline.runtime-5rRYZuX5.js → pipeline.runtime-mFCCSllA.js} +2094 -1953
  26. package/dist/{policy-C31RYSuT.js → policy-DVg6FyMP.js} +1 -1
  27. package/dist/{probe-CVRuArHA.js → probe-BhQTDVBQ.js} +50 -57
  28. package/dist/{provider-htuIJGFD.js → provider-PSppCU_K.js} +83 -65
  29. package/dist/{relay-source-Df9EaiTF.js → relay-source-D0mb_JBk.js} +1 -1
  30. package/dist/{replies-Cgr2Gli4.js → replies-BkPPM2Ri.js} +50 -13
  31. package/dist/{resolve-channels-DodP2TFx.js → resolve-channels-B3RlJKyV.js} +2 -2
  32. package/dist/{resolve-users-M9eF8891.js → resolve-users-DTm7PEMa.js} +2 -2
  33. package/dist/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-8H4AJuhK.js} +1 -0
  34. package/dist/{runtime-api-D5XYMMsf.js → runtime-api-jpn3vQ7e.js} +2 -2
  35. package/dist/runtime-api.js +10 -10
  36. package/dist/{scopes-CJRpHkDC.js → scopes-B2SqZ--4.js} +1 -1
  37. package/dist/{security-audit-Cz6erklv.js → security-audit-DR097212.js} +1 -1
  38. package/dist/security-contract-api.js +1 -1
  39. package/dist/{send-BZ1tPv7-.js → send-2IoDXPeB.js} +7 -21
  40. package/dist/{send.runtime-a2pilFor.js → send.runtime-BKd_PAEw.js} +1 -1
  41. package/dist/setup-plugin-api.js +1 -1
  42. package/dist/{setup-surface-wV-S1dE_.js → setup-surface-Dyam58nO.js} +8 -16
  43. package/dist/{shared-BfMskaMx.js → shared-g55DV75U.js} +14 -36
  44. package/dist/{slash-dispatch.runtime-lfeIsXTX.js → slash-dispatch.runtime-BRQbvn2e.js} +10 -9
  45. package/node_modules/@slack/bolt/dist/App.d.ts +4 -19
  46. package/node_modules/@slack/bolt/dist/App.d.ts.map +1 -1
  47. package/node_modules/@slack/bolt/dist/App.js +21 -40
  48. package/node_modules/@slack/bolt/dist/App.js.map +1 -1
  49. package/node_modules/@slack/bolt/dist/context/create-respond.d.ts +3 -3
  50. package/node_modules/@slack/bolt/dist/context/create-respond.d.ts.map +1 -1
  51. package/node_modules/@slack/bolt/dist/context/create-respond.js +13 -2
  52. package/node_modules/@slack/bolt/dist/context/create-respond.js.map +1 -1
  53. package/node_modules/@slack/bolt/dist/errors.d.ts +6 -8
  54. package/node_modules/@slack/bolt/dist/errors.d.ts.map +1 -1
  55. package/node_modules/@slack/bolt/dist/errors.js +11 -11
  56. package/node_modules/@slack/bolt/dist/errors.js.map +1 -1
  57. package/node_modules/@slack/bolt/dist/helpers.d.ts.map +1 -1
  58. package/node_modules/@slack/bolt/dist/helpers.js +1 -2
  59. package/node_modules/@slack/bolt/dist/helpers.js.map +1 -1
  60. package/node_modules/@slack/bolt/dist/index.d.ts +0 -1
  61. package/node_modules/@slack/bolt/dist/index.d.ts.map +1 -1
  62. package/node_modules/@slack/bolt/dist/index.js +1 -3
  63. package/node_modules/@slack/bolt/dist/index.js.map +1 -1
  64. package/node_modules/@slack/bolt/dist/receivers/AwsLambdaReceiver.d.ts +10 -1
  65. package/node_modules/@slack/bolt/dist/receivers/AwsLambdaReceiver.d.ts.map +1 -1
  66. package/node_modules/@slack/bolt/dist/receivers/AwsLambdaReceiver.js +5 -1
  67. package/node_modules/@slack/bolt/dist/receivers/AwsLambdaReceiver.js.map +1 -1
  68. package/node_modules/@slack/bolt/dist/receivers/HTTPModuleFunctions.d.ts.map +1 -1
  69. package/node_modules/@slack/bolt/dist/receivers/HTTPModuleFunctions.js +10 -14
  70. package/node_modules/@slack/bolt/dist/receivers/HTTPModuleFunctions.js.map +1 -1
  71. package/node_modules/@slack/bolt/dist/receivers/SocketModeFunctions.d.ts.map +1 -1
  72. package/node_modules/@slack/bolt/dist/receivers/SocketModeFunctions.js +1 -1
  73. package/node_modules/@slack/bolt/dist/receivers/SocketModeFunctions.js.map +1 -1
  74. package/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.d.ts +3 -1
  75. package/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.d.ts.map +1 -1
  76. package/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.js +2 -1
  77. package/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.js.map +1 -1
  78. package/node_modules/@slack/bolt/dist/types/actions/index.d.ts +2 -4
  79. package/node_modules/@slack/bolt/dist/types/actions/index.d.ts.map +1 -1
  80. package/node_modules/@slack/bolt/dist/types/actions/index.js +0 -2
  81. package/node_modules/@slack/bolt/dist/types/actions/index.js.map +1 -1
  82. package/node_modules/@slack/bolt/dist/types/events/index.d.ts +2 -0
  83. package/node_modules/@slack/bolt/dist/types/events/index.d.ts.map +1 -1
  84. package/node_modules/@slack/bolt/dist/types/utilities.d.ts +2 -2
  85. package/node_modules/@slack/bolt/dist/types/utilities.d.ts.map +1 -1
  86. package/node_modules/@slack/bolt/dist/types/view/index.d.ts +1 -31
  87. package/node_modules/@slack/bolt/dist/types/view/index.d.ts.map +1 -1
  88. package/node_modules/@slack/bolt/package.json +10 -11
  89. package/node_modules/@slack/logger/README.md +1 -1
  90. package/node_modules/@slack/logger/dist/index.js +17 -13
  91. package/node_modules/@slack/logger/dist/index.js.map +1 -1
  92. package/node_modules/@slack/logger/package.json +6 -7
  93. package/node_modules/@slack/oauth/README.md +1 -1
  94. package/node_modules/@slack/oauth/dist/errors.d.ts +25 -14
  95. package/node_modules/@slack/oauth/dist/errors.d.ts.map +1 -1
  96. package/node_modules/@slack/oauth/dist/errors.js +24 -33
  97. package/node_modules/@slack/oauth/dist/errors.js.map +1 -1
  98. package/node_modules/@slack/oauth/dist/install-provider.js +58 -16
  99. package/node_modules/@slack/oauth/dist/install-provider.js.map +1 -1
  100. package/node_modules/@slack/oauth/dist/installation-stores/file-store.js +4 -2
  101. package/node_modules/@slack/oauth/dist/installation-stores/file-store.js.map +1 -1
  102. package/node_modules/@slack/oauth/dist/installation-stores/memory-store.js +3 -16
  103. package/node_modules/@slack/oauth/dist/installation-stores/memory-store.js.map +1 -1
  104. package/node_modules/@slack/oauth/dist/state-stores/clear-state-store.js +2 -0
  105. package/node_modules/@slack/oauth/dist/state-stores/clear-state-store.js.map +1 -1
  106. package/node_modules/@slack/oauth/dist/state-stores/file-state-store.js +3 -0
  107. package/node_modules/@slack/oauth/dist/state-stores/file-state-store.js.map +1 -1
  108. package/node_modules/@slack/oauth/package.json +8 -9
  109. package/node_modules/@slack/socket-mode/README.md +1 -1
  110. package/node_modules/@slack/socket-mode/dist/package.json +21 -13
  111. package/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.d.ts +14 -8
  112. package/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.d.ts.map +1 -1
  113. package/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.js +136 -48
  114. package/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.js.map +1 -1
  115. package/node_modules/@slack/socket-mode/dist/src/SocketModeClient.d.ts +12 -6
  116. package/node_modules/@slack/socket-mode/dist/src/SocketModeClient.d.ts.map +1 -1
  117. package/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js +87 -38
  118. package/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js.map +1 -1
  119. package/node_modules/@slack/socket-mode/dist/src/SocketModeOptions.d.ts +31 -1
  120. package/node_modules/@slack/socket-mode/dist/src/SocketModeOptions.d.ts.map +1 -1
  121. package/node_modules/@slack/socket-mode/dist/src/errors.d.ts +31 -37
  122. package/node_modules/@slack/socket-mode/dist/src/errors.d.ts.map +1 -1
  123. package/node_modules/@slack/socket-mode/dist/src/errors.js +43 -47
  124. package/node_modules/@slack/socket-mode/dist/src/errors.js.map +1 -1
  125. package/node_modules/@slack/socket-mode/dist/src/index.d.ts +2 -2
  126. package/node_modules/@slack/socket-mode/dist/src/index.d.ts.map +1 -1
  127. package/node_modules/@slack/socket-mode/dist/src/index.js +7 -1
  128. package/node_modules/@slack/socket-mode/dist/src/index.js.map +1 -1
  129. package/node_modules/@slack/socket-mode/package.json +21 -13
  130. package/node_modules/@slack/types/README.md +1 -1
  131. package/node_modules/@slack/types/dist/events/app.d.ts +28 -0
  132. package/node_modules/@slack/types/dist/events/app.d.ts.map +1 -1
  133. package/node_modules/@slack/types/dist/events/index.d.ts +2 -2
  134. package/node_modules/@slack/types/dist/events/index.d.ts.map +1 -1
  135. package/node_modules/@slack/types/dist/events/index.js.map +1 -1
  136. package/node_modules/@slack/types/dist/events/message.d.ts +2 -0
  137. package/node_modules/@slack/types/dist/events/message.d.ts.map +1 -1
  138. package/node_modules/@slack/types/package.json +3 -3
  139. package/node_modules/@slack/web-api/README.md +1 -1
  140. package/node_modules/@slack/web-api/dist/WebClient.d.ts +42 -71
  141. package/node_modules/@slack/web-api/dist/WebClient.d.ts.map +1 -1
  142. package/node_modules/@slack/web-api/dist/WebClient.js +180 -248
  143. package/node_modules/@slack/web-api/dist/WebClient.js.map +1 -1
  144. package/node_modules/@slack/web-api/dist/chat-stream.js +37 -22
  145. package/node_modules/@slack/web-api/dist/chat-stream.js.map +1 -1
  146. package/node_modules/@slack/web-api/dist/errors.d.ts +32 -51
  147. package/node_modules/@slack/web-api/dist/errors.d.ts.map +1 -1
  148. package/node_modules/@slack/web-api/dist/errors.js +64 -55
  149. package/node_modules/@slack/web-api/dist/errors.js.map +1 -1
  150. package/node_modules/@slack/web-api/dist/file-upload.d.ts +0 -9
  151. package/node_modules/@slack/web-api/dist/file-upload.d.ts.map +1 -1
  152. package/node_modules/@slack/web-api/dist/file-upload.js +41 -46
  153. package/node_modules/@slack/web-api/dist/file-upload.js.map +1 -1
  154. package/node_modules/@slack/web-api/dist/index.d.ts +2 -2
  155. package/node_modules/@slack/web-api/dist/index.d.ts.map +1 -1
  156. package/node_modules/@slack/web-api/dist/index.js +8 -1
  157. package/node_modules/@slack/web-api/dist/index.js.map +1 -1
  158. package/node_modules/@slack/web-api/dist/methods.d.ts +2 -38
  159. package/node_modules/@slack/web-api/dist/methods.d.ts.map +1 -1
  160. package/node_modules/@slack/web-api/dist/methods.js +1347 -1384
  161. package/node_modules/@slack/web-api/dist/methods.js.map +1 -1
  162. package/node_modules/@slack/web-api/dist/types/request/files.d.ts +0 -1
  163. package/node_modules/@slack/web-api/dist/types/request/files.d.ts.map +1 -1
  164. package/node_modules/@slack/web-api/dist/types/request/index.d.ts +3 -3
  165. package/node_modules/@slack/web-api/dist/types/request/index.d.ts.map +1 -1
  166. package/node_modules/@slack/web-api/dist/types/request/manifest.d.ts +66 -1
  167. package/node_modules/@slack/web-api/dist/types/request/manifest.d.ts.map +1 -1
  168. package/node_modules/@slack/web-api/dist/types/request/rtm.d.ts +1 -14
  169. package/node_modules/@slack/web-api/dist/types/request/rtm.d.ts.map +1 -1
  170. package/node_modules/@slack/web-api/dist/types/request/workflows.d.ts +0 -29
  171. package/node_modules/@slack/web-api/dist/types/request/workflows.d.ts.map +1 -1
  172. package/node_modules/@slack/web-api/package.json +6 -10
  173. package/node_modules/@types/retry/LICENSE +21 -21
  174. package/node_modules/@types/retry/README.md +5 -4
  175. package/node_modules/@types/retry/index.d.ts +20 -13
  176. package/node_modules/@types/retry/package.json +9 -11
  177. package/node_modules/{es-set-tostringtag → undici}/LICENSE +1 -1
  178. package/node_modules/undici/README.md +741 -0
  179. package/node_modules/undici/docs/docs/api/Agent.md +84 -0
  180. package/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
  181. package/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
  182. package/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
  183. package/node_modules/undici/docs/docs/api/Client.md +288 -0
  184. package/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
  185. package/node_modules/undici/docs/docs/api/Connector.md +115 -0
  186. package/node_modules/undici/docs/docs/api/ContentType.md +57 -0
  187. package/node_modules/undici/docs/docs/api/Cookies.md +128 -0
  188. package/node_modules/undici/docs/docs/api/Debug.md +62 -0
  189. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +315 -0
  190. package/node_modules/undici/docs/docs/api/Dispatcher.md +1392 -0
  191. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +159 -0
  192. package/node_modules/undici/docs/docs/api/Errors.md +49 -0
  193. package/node_modules/undici/docs/docs/api/EventSource.md +45 -0
  194. package/node_modules/undici/docs/docs/api/Fetch.md +60 -0
  195. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +139 -0
  196. package/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
  197. package/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
  198. package/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
  199. package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
  200. package/node_modules/undici/docs/docs/api/MockClient.md +81 -0
  201. package/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
  202. package/node_modules/undici/docs/docs/api/MockPool.md +555 -0
  203. package/node_modules/undici/docs/docs/api/Pool.md +84 -0
  204. package/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
  205. package/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
  206. package/node_modules/undici/docs/docs/api/RedirectHandler.md +93 -0
  207. package/node_modules/undici/docs/docs/api/RetryAgent.md +50 -0
  208. package/node_modules/undici/docs/docs/api/RetryHandler.md +118 -0
  209. package/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
  210. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +616 -0
  211. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
  212. package/node_modules/undici/docs/docs/api/Util.md +25 -0
  213. package/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
  214. package/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
  215. package/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
  216. package/node_modules/undici/docs/docs/best-practices/crawling.md +58 -0
  217. package/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
  218. package/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
  219. package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +224 -0
  220. package/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
  221. package/node_modules/undici/index-fetch.js +65 -0
  222. package/node_modules/undici/index.d.ts +3 -0
  223. package/node_modules/undici/index.js +234 -0
  224. package/node_modules/undici/lib/api/abort-signal.js +59 -0
  225. package/node_modules/undici/lib/api/api-connect.js +110 -0
  226. package/node_modules/undici/lib/api/api-pipeline.js +252 -0
  227. package/node_modules/undici/lib/api/api-request.js +214 -0
  228. package/node_modules/undici/lib/api/api-stream.js +209 -0
  229. package/node_modules/undici/lib/api/api-upgrade.js +111 -0
  230. package/node_modules/undici/lib/api/index.js +7 -0
  231. package/node_modules/undici/lib/api/readable.js +580 -0
  232. package/node_modules/undici/lib/cache/memory-cache-store.js +234 -0
  233. package/node_modules/undici/lib/cache/sqlite-cache-store.js +461 -0
  234. package/node_modules/undici/lib/core/connect.js +153 -0
  235. package/node_modules/undici/lib/core/constants.js +143 -0
  236. package/node_modules/undici/lib/core/diagnostics.js +227 -0
  237. package/node_modules/undici/lib/core/errors.js +477 -0
  238. package/node_modules/undici/lib/core/request.js +453 -0
  239. package/node_modules/undici/lib/core/socks5-client.js +422 -0
  240. package/node_modules/undici/lib/core/socks5-utils.js +212 -0
  241. package/node_modules/undici/lib/core/symbols.js +75 -0
  242. package/node_modules/undici/lib/core/tree.js +160 -0
  243. package/node_modules/undici/lib/core/util.js +992 -0
  244. package/node_modules/undici/lib/dispatcher/agent.js +158 -0
  245. package/node_modules/undici/lib/dispatcher/balanced-pool.js +219 -0
  246. package/node_modules/undici/lib/dispatcher/client-h1.js +1722 -0
  247. package/node_modules/undici/lib/dispatcher/client-h2.js +995 -0
  248. package/node_modules/undici/lib/dispatcher/client.js +664 -0
  249. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +184 -0
  250. package/node_modules/undici/lib/dispatcher/dispatcher.js +48 -0
  251. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
  252. package/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
  253. package/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
  254. package/node_modules/undici/lib/dispatcher/pool-base.js +214 -0
  255. package/node_modules/undici/lib/dispatcher/pool.js +118 -0
  256. package/node_modules/undici/lib/dispatcher/proxy-agent.js +319 -0
  257. package/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
  258. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +137 -0
  259. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +260 -0
  260. package/node_modules/undici/lib/encoding/index.js +33 -0
  261. package/node_modules/undici/lib/global.js +59 -0
  262. package/node_modules/undici/lib/handler/cache-handler.js +578 -0
  263. package/node_modules/undici/lib/handler/cache-revalidation-handler.js +124 -0
  264. package/node_modules/undici/lib/handler/decorator-handler.js +67 -0
  265. package/node_modules/undici/lib/handler/deduplication-handler.js +460 -0
  266. package/node_modules/undici/lib/handler/redirect-handler.js +238 -0
  267. package/node_modules/undici/lib/handler/retry-handler.js +394 -0
  268. package/node_modules/undici/lib/handler/unwrap-handler.js +106 -0
  269. package/node_modules/undici/lib/handler/wrap-handler.js +105 -0
  270. package/node_modules/undici/lib/interceptor/cache.js +495 -0
  271. package/node_modules/undici/lib/interceptor/decompress.js +259 -0
  272. package/node_modules/undici/lib/interceptor/deduplicate.js +117 -0
  273. package/node_modules/undici/lib/interceptor/dns.js +571 -0
  274. package/node_modules/undici/lib/interceptor/dump.js +112 -0
  275. package/node_modules/undici/lib/interceptor/redirect.js +21 -0
  276. package/node_modules/undici/lib/interceptor/response-error.js +95 -0
  277. package/node_modules/undici/lib/interceptor/retry.js +19 -0
  278. package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  279. package/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
  280. package/node_modules/undici/lib/llhttp/constants.js +531 -0
  281. package/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
  282. package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
  283. package/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
  284. package/node_modules/undici/lib/llhttp/utils.js +12 -0
  285. package/node_modules/undici/lib/mock/mock-agent.js +232 -0
  286. package/node_modules/undici/lib/mock/mock-call-history.js +248 -0
  287. package/node_modules/undici/lib/mock/mock-client.js +68 -0
  288. package/node_modules/undici/lib/mock/mock-errors.js +29 -0
  289. package/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
  290. package/node_modules/undici/lib/mock/mock-pool.js +68 -0
  291. package/node_modules/undici/lib/mock/mock-symbols.js +32 -0
  292. package/node_modules/undici/lib/mock/mock-utils.js +486 -0
  293. package/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
  294. package/node_modules/undici/lib/mock/snapshot-agent.js +353 -0
  295. package/node_modules/undici/lib/mock/snapshot-recorder.js +588 -0
  296. package/node_modules/undici/lib/mock/snapshot-utils.js +158 -0
  297. package/node_modules/undici/lib/util/cache.js +414 -0
  298. package/node_modules/undici/lib/util/date.js +653 -0
  299. package/node_modules/undici/lib/util/promise.js +28 -0
  300. package/node_modules/undici/lib/util/runtime-features.js +124 -0
  301. package/node_modules/undici/lib/util/stats.js +32 -0
  302. package/node_modules/undici/lib/util/timers.js +425 -0
  303. package/node_modules/undici/lib/web/cache/cache.js +864 -0
  304. package/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
  305. package/node_modules/undici/lib/web/cache/util.js +45 -0
  306. package/node_modules/undici/lib/web/cookies/constants.js +12 -0
  307. package/node_modules/undici/lib/web/cookies/index.js +199 -0
  308. package/node_modules/undici/lib/web/cookies/parse.js +314 -0
  309. package/node_modules/undici/lib/web/cookies/util.js +282 -0
  310. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +399 -0
  311. package/node_modules/undici/lib/web/eventsource/eventsource.js +501 -0
  312. package/node_modules/undici/lib/web/eventsource/util.js +29 -0
  313. package/node_modules/{has-tostringtag → undici/lib/web/fetch}/LICENSE +1 -1
  314. package/node_modules/undici/lib/web/fetch/body.js +509 -0
  315. package/node_modules/undici/lib/web/fetch/constants.js +131 -0
  316. package/node_modules/undici/lib/web/fetch/data-url.js +596 -0
  317. package/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
  318. package/node_modules/undici/lib/web/fetch/formdata.js +259 -0
  319. package/node_modules/undici/lib/web/fetch/global.js +40 -0
  320. package/node_modules/undici/lib/web/fetch/headers.js +719 -0
  321. package/node_modules/undici/lib/web/fetch/index.js +2413 -0
  322. package/node_modules/undici/lib/web/fetch/request.js +1115 -0
  323. package/node_modules/undici/lib/web/fetch/response.js +641 -0
  324. package/node_modules/undici/lib/web/fetch/util.js +1522 -0
  325. package/node_modules/undici/lib/web/infra/index.js +229 -0
  326. package/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
  327. package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
  328. package/node_modules/undici/lib/web/webidl/index.js +1006 -0
  329. package/node_modules/undici/lib/web/websocket/connection.js +329 -0
  330. package/node_modules/undici/lib/web/websocket/constants.js +126 -0
  331. package/node_modules/undici/lib/web/websocket/events.js +331 -0
  332. package/node_modules/undici/lib/web/websocket/frame.js +133 -0
  333. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +100 -0
  334. package/node_modules/undici/lib/web/websocket/receiver.js +507 -0
  335. package/node_modules/undici/lib/web/websocket/sender.js +109 -0
  336. package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +104 -0
  337. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +498 -0
  338. package/node_modules/undici/lib/web/websocket/util.js +347 -0
  339. package/node_modules/undici/lib/web/websocket/websocket.js +758 -0
  340. package/node_modules/undici/package.json +152 -0
  341. package/node_modules/undici/scripts/strip-comments.js +10 -0
  342. package/node_modules/undici/types/README.md +6 -0
  343. package/node_modules/undici/types/agent.d.ts +32 -0
  344. package/node_modules/undici/types/api.d.ts +43 -0
  345. package/node_modules/undici/types/balanced-pool.d.ts +30 -0
  346. package/node_modules/undici/types/cache-interceptor.d.ts +179 -0
  347. package/node_modules/undici/types/cache.d.ts +36 -0
  348. package/node_modules/undici/types/client-stats.d.ts +15 -0
  349. package/node_modules/undici/types/client.d.ts +139 -0
  350. package/node_modules/undici/types/connector.d.ts +36 -0
  351. package/node_modules/undici/types/content-type.d.ts +21 -0
  352. package/node_modules/undici/types/cookies.d.ts +30 -0
  353. package/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
  354. package/node_modules/undici/types/dispatcher.d.ts +275 -0
  355. package/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
  356. package/node_modules/undici/types/errors.d.ts +177 -0
  357. package/node_modules/undici/types/eventsource.d.ts +66 -0
  358. package/node_modules/undici/types/fetch.d.ts +231 -0
  359. package/node_modules/undici/types/formdata.d.ts +114 -0
  360. package/node_modules/undici/types/global-dispatcher.d.ts +9 -0
  361. package/node_modules/undici/types/global-origin.d.ts +7 -0
  362. package/node_modules/undici/types/h2c-client.d.ts +73 -0
  363. package/node_modules/undici/types/handlers.d.ts +14 -0
  364. package/node_modules/undici/types/header.d.ts +160 -0
  365. package/node_modules/undici/types/index.d.ts +91 -0
  366. package/node_modules/undici/types/interceptors.d.ts +80 -0
  367. package/node_modules/undici/types/mock-agent.d.ts +68 -0
  368. package/node_modules/undici/types/mock-call-history.d.ts +111 -0
  369. package/node_modules/undici/types/mock-client.d.ts +27 -0
  370. package/node_modules/undici/types/mock-errors.d.ts +12 -0
  371. package/node_modules/undici/types/mock-interceptor.d.ts +94 -0
  372. package/node_modules/undici/types/mock-pool.d.ts +27 -0
  373. package/node_modules/undici/types/patch.d.ts +29 -0
  374. package/node_modules/undici/types/pool-stats.d.ts +19 -0
  375. package/node_modules/undici/types/pool.d.ts +41 -0
  376. package/node_modules/undici/types/proxy-agent.d.ts +29 -0
  377. package/node_modules/undici/types/readable.d.ts +68 -0
  378. package/node_modules/undici/types/retry-agent.d.ts +8 -0
  379. package/node_modules/undici/types/retry-handler.d.ts +125 -0
  380. package/node_modules/undici/types/round-robin-pool.d.ts +41 -0
  381. package/node_modules/undici/types/snapshot-agent.d.ts +109 -0
  382. package/node_modules/undici/types/socks5-proxy-agent.d.ts +25 -0
  383. package/node_modules/undici/types/util.d.ts +18 -0
  384. package/node_modules/undici/types/utility.d.ts +7 -0
  385. package/node_modules/undici/types/webidl.d.ts +347 -0
  386. package/node_modules/undici/types/websocket.d.ts +188 -0
  387. package/openclaw.plugin.json +8 -38
  388. package/package.json +11 -8
  389. package/dist/action-runtime.runtime-9-17zvKH.js +0 -2
  390. package/dist/doctor-contract-U6oVntbM.js +0 -173
  391. package/dist/interactive-replies-C3ffk6oN.js +0 -197
  392. package/dist/interactive-replies-api.js +0 -2
  393. package/node_modules/@slack/bolt/dist/WorkflowStep.d.ts +0 -159
  394. package/node_modules/@slack/bolt/dist/WorkflowStep.d.ts.map +0 -1
  395. package/node_modules/@slack/bolt/dist/WorkflowStep.js +0 -217
  396. package/node_modules/@slack/bolt/dist/WorkflowStep.js.map +0 -1
  397. package/node_modules/@slack/bolt/dist/types/actions/workflow-step-edit.d.ts +0 -49
  398. package/node_modules/@slack/bolt/dist/types/actions/workflow-step-edit.d.ts.map +0 -1
  399. package/node_modules/@slack/bolt/dist/types/actions/workflow-step-edit.js +0 -3
  400. package/node_modules/@slack/bolt/dist/types/actions/workflow-step-edit.js.map +0 -1
  401. package/node_modules/@types/ws/LICENSE +0 -21
  402. package/node_modules/@types/ws/README.md +0 -15
  403. package/node_modules/@types/ws/index.d.mts +0 -451
  404. package/node_modules/@types/ws/index.d.ts +0 -445
  405. package/node_modules/@types/ws/package.json +0 -72
  406. package/node_modules/agent-base/README.md +0 -145
  407. package/node_modules/agent-base/dist/src/index.d.ts +0 -78
  408. package/node_modules/agent-base/dist/src/index.js +0 -203
  409. package/node_modules/agent-base/dist/src/index.js.map +0 -1
  410. package/node_modules/agent-base/dist/src/promisify.d.ts +0 -4
  411. package/node_modules/agent-base/dist/src/promisify.js +0 -18
  412. package/node_modules/agent-base/dist/src/promisify.js.map +0 -1
  413. package/node_modules/agent-base/package.json +0 -64
  414. package/node_modules/agent-base/src/index.ts +0 -345
  415. package/node_modules/agent-base/src/promisify.ts +0 -33
  416. package/node_modules/asynckit/LICENSE +0 -21
  417. package/node_modules/asynckit/README.md +0 -233
  418. package/node_modules/asynckit/bench.js +0 -76
  419. package/node_modules/asynckit/index.js +0 -6
  420. package/node_modules/asynckit/lib/abort.js +0 -29
  421. package/node_modules/asynckit/lib/async.js +0 -34
  422. package/node_modules/asynckit/lib/defer.js +0 -26
  423. package/node_modules/asynckit/lib/iterate.js +0 -75
  424. package/node_modules/asynckit/lib/readable_asynckit.js +0 -91
  425. package/node_modules/asynckit/lib/readable_parallel.js +0 -25
  426. package/node_modules/asynckit/lib/readable_serial.js +0 -25
  427. package/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
  428. package/node_modules/asynckit/lib/state.js +0 -37
  429. package/node_modules/asynckit/lib/streamify.js +0 -141
  430. package/node_modules/asynckit/lib/terminator.js +0 -29
  431. package/node_modules/asynckit/package.json +0 -63
  432. package/node_modules/asynckit/parallel.js +0 -43
  433. package/node_modules/asynckit/serial.js +0 -17
  434. package/node_modules/asynckit/serialOrdered.js +0 -75
  435. package/node_modules/asynckit/stream.js +0 -21
  436. package/node_modules/axios/CHANGELOG.md +0 -1872
  437. package/node_modules/axios/LICENSE +0 -7
  438. package/node_modules/axios/MIGRATION_GUIDE.md +0 -877
  439. package/node_modules/axios/README.md +0 -2559
  440. package/node_modules/axios/dist/axios.js +0 -5249
  441. package/node_modules/axios/dist/axios.min.js +0 -5
  442. package/node_modules/axios/dist/axios.min.js.map +0 -1
  443. package/node_modules/axios/dist/browser/axios.cjs +0 -5146
  444. package/node_modules/axios/dist/esm/axios.js +0 -5167
  445. package/node_modules/axios/dist/esm/axios.min.js +0 -3
  446. package/node_modules/axios/dist/esm/axios.min.js.map +0 -1
  447. package/node_modules/axios/dist/node/axios.cjs +0 -5996
  448. package/node_modules/axios/index.d.cts +0 -738
  449. package/node_modules/axios/index.d.ts +0 -755
  450. package/node_modules/axios/index.js +0 -45
  451. package/node_modules/axios/lib/adapters/README.md +0 -36
  452. package/node_modules/axios/lib/adapters/adapters.js +0 -132
  453. package/node_modules/axios/lib/adapters/fetch.js +0 -643
  454. package/node_modules/axios/lib/adapters/http.js +0 -1417
  455. package/node_modules/axios/lib/adapters/xhr.js +0 -228
  456. package/node_modules/axios/lib/axios.js +0 -89
  457. package/node_modules/axios/lib/cancel/CancelToken.js +0 -135
  458. package/node_modules/axios/lib/cancel/CanceledError.js +0 -22
  459. package/node_modules/axios/lib/cancel/isCancel.js +0 -5
  460. package/node_modules/axios/lib/core/Axios.js +0 -283
  461. package/node_modules/axios/lib/core/AxiosError.js +0 -188
  462. package/node_modules/axios/lib/core/AxiosHeaders.js +0 -351
  463. package/node_modules/axios/lib/core/InterceptorManager.js +0 -72
  464. package/node_modules/axios/lib/core/README.md +0 -8
  465. package/node_modules/axios/lib/core/buildFullPath.js +0 -50
  466. package/node_modules/axios/lib/core/dispatchRequest.js +0 -89
  467. package/node_modules/axios/lib/core/mergeConfig.js +0 -159
  468. package/node_modules/axios/lib/core/settle.js +0 -27
  469. package/node_modules/axios/lib/core/transformData.js +0 -28
  470. package/node_modules/axios/lib/defaults/index.js +0 -177
  471. package/node_modules/axios/lib/defaults/transitional.js +0 -10
  472. package/node_modules/axios/lib/env/README.md +0 -3
  473. package/node_modules/axios/lib/env/classes/FormData.js +0 -2
  474. package/node_modules/axios/lib/env/data.js +0 -1
  475. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +0 -156
  476. package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -59
  477. package/node_modules/axios/lib/helpers/Http2Sessions.js +0 -119
  478. package/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -77
  479. package/node_modules/axios/lib/helpers/README.md +0 -7
  480. package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +0 -29
  481. package/node_modules/axios/lib/helpers/bind.js +0 -14
  482. package/node_modules/axios/lib/helpers/buildURL.js +0 -69
  483. package/node_modules/axios/lib/helpers/callbackify.js +0 -18
  484. package/node_modules/axios/lib/helpers/combineURLs.js +0 -15
  485. package/node_modules/axios/lib/helpers/composeSignals.js +0 -57
  486. package/node_modules/axios/lib/helpers/cookies.js +0 -64
  487. package/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -31
  488. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +0 -105
  489. package/node_modules/axios/lib/helpers/formDataToJSON.js +0 -119
  490. package/node_modules/axios/lib/helpers/formDataToStream.js +0 -119
  491. package/node_modules/axios/lib/helpers/fromDataURI.js +0 -68
  492. package/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -19
  493. package/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
  494. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -16
  495. package/node_modules/axios/lib/helpers/null.js +0 -2
  496. package/node_modules/axios/lib/helpers/parseHeaders.js +0 -69
  497. package/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
  498. package/node_modules/axios/lib/helpers/progressEventReducer.js +0 -54
  499. package/node_modules/axios/lib/helpers/readBlob.js +0 -15
  500. package/node_modules/axios/lib/helpers/resolveConfig.js +0 -119
  501. package/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +0 -60
  502. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +0 -210
  503. package/node_modules/axios/lib/helpers/speedometer.js +0 -55
  504. package/node_modules/axios/lib/helpers/spread.js +0 -28
  505. package/node_modules/axios/lib/helpers/throttle.js +0 -44
  506. package/node_modules/axios/lib/helpers/toFormData.js +0 -285
  507. package/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -19
  508. package/node_modules/axios/lib/helpers/trackStream.js +0 -89
  509. package/node_modules/axios/lib/helpers/validator.js +0 -112
  510. package/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
  511. package/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
  512. package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -4
  513. package/node_modules/axios/lib/platform/browser/index.js +0 -13
  514. package/node_modules/axios/lib/platform/common/utils.js +0 -52
  515. package/node_modules/axios/lib/platform/index.js +0 -7
  516. package/node_modules/axios/lib/platform/node/classes/FormData.js +0 -3
  517. package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +0 -4
  518. package/node_modules/axios/lib/platform/node/index.js +0 -37
  519. package/node_modules/axios/lib/utils.js +0 -1017
  520. package/node_modules/axios/package.json +0 -201
  521. package/node_modules/combined-stream/License +0 -19
  522. package/node_modules/combined-stream/Readme.md +0 -138
  523. package/node_modules/combined-stream/lib/combined_stream.js +0 -208
  524. package/node_modules/combined-stream/package.json +0 -25
  525. package/node_modules/delayed-stream/.npmignore +0 -1
  526. package/node_modules/delayed-stream/License +0 -19
  527. package/node_modules/delayed-stream/Makefile +0 -7
  528. package/node_modules/delayed-stream/Readme.md +0 -141
  529. package/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
  530. package/node_modules/delayed-stream/package.json +0 -27
  531. package/node_modules/es-set-tostringtag/.eslintrc +0 -13
  532. package/node_modules/es-set-tostringtag/.nycrc +0 -9
  533. package/node_modules/es-set-tostringtag/CHANGELOG.md +0 -67
  534. package/node_modules/es-set-tostringtag/README.md +0 -53
  535. package/node_modules/es-set-tostringtag/index.d.ts +0 -10
  536. package/node_modules/es-set-tostringtag/index.js +0 -35
  537. package/node_modules/es-set-tostringtag/package.json +0 -78
  538. package/node_modules/es-set-tostringtag/test/index.js +0 -85
  539. package/node_modules/es-set-tostringtag/tsconfig.json +0 -9
  540. package/node_modules/follow-redirects/LICENSE +0 -18
  541. package/node_modules/follow-redirects/README.md +0 -157
  542. package/node_modules/follow-redirects/debug.js +0 -15
  543. package/node_modules/follow-redirects/http.js +0 -1
  544. package/node_modules/follow-redirects/https.js +0 -1
  545. package/node_modules/follow-redirects/index.js +0 -709
  546. package/node_modules/follow-redirects/package.json +0 -58
  547. package/node_modules/form-data/CHANGELOG.md +0 -669
  548. package/node_modules/form-data/License +0 -19
  549. package/node_modules/form-data/README.md +0 -350
  550. package/node_modules/form-data/index.d.ts +0 -51
  551. package/node_modules/form-data/lib/browser.js +0 -4
  552. package/node_modules/form-data/lib/form_data.js +0 -514
  553. package/node_modules/form-data/lib/populate.js +0 -10
  554. package/node_modules/form-data/node_modules/mime-db/HISTORY.md +0 -507
  555. package/node_modules/form-data/node_modules/mime-db/LICENSE +0 -23
  556. package/node_modules/form-data/node_modules/mime-db/README.md +0 -100
  557. package/node_modules/form-data/node_modules/mime-db/db.json +0 -8519
  558. package/node_modules/form-data/node_modules/mime-db/index.js +0 -12
  559. package/node_modules/form-data/node_modules/mime-db/package.json +0 -60
  560. package/node_modules/form-data/node_modules/mime-types/HISTORY.md +0 -397
  561. package/node_modules/form-data/node_modules/mime-types/LICENSE +0 -23
  562. package/node_modules/form-data/node_modules/mime-types/README.md +0 -113
  563. package/node_modules/form-data/node_modules/mime-types/index.js +0 -188
  564. package/node_modules/form-data/node_modules/mime-types/package.json +0 -44
  565. package/node_modules/form-data/package.json +0 -83
  566. package/node_modules/has-tostringtag/.eslintrc +0 -5
  567. package/node_modules/has-tostringtag/.github/FUNDING.yml +0 -12
  568. package/node_modules/has-tostringtag/.nycrc +0 -13
  569. package/node_modules/has-tostringtag/CHANGELOG.md +0 -42
  570. package/node_modules/has-tostringtag/README.md +0 -46
  571. package/node_modules/has-tostringtag/index.d.ts +0 -3
  572. package/node_modules/has-tostringtag/index.js +0 -8
  573. package/node_modules/has-tostringtag/package.json +0 -108
  574. package/node_modules/has-tostringtag/shams.d.ts +0 -3
  575. package/node_modules/has-tostringtag/shams.js +0 -8
  576. package/node_modules/has-tostringtag/test/index.js +0 -21
  577. package/node_modules/has-tostringtag/test/shams/core-js.js +0 -31
  578. package/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +0 -30
  579. package/node_modules/has-tostringtag/test/tests.js +0 -15
  580. package/node_modules/has-tostringtag/tsconfig.json +0 -49
  581. package/node_modules/https-proxy-agent/README.md +0 -137
  582. package/node_modules/https-proxy-agent/dist/agent.d.ts +0 -30
  583. package/node_modules/https-proxy-agent/dist/agent.js +0 -177
  584. package/node_modules/https-proxy-agent/dist/agent.js.map +0 -1
  585. package/node_modules/https-proxy-agent/dist/index.d.ts +0 -23
  586. package/node_modules/https-proxy-agent/dist/index.js +0 -14
  587. package/node_modules/https-proxy-agent/dist/index.js.map +0 -1
  588. package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +0 -7
  589. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +0 -66
  590. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +0 -1
  591. package/node_modules/https-proxy-agent/package.json +0 -56
  592. package/node_modules/is-electron/LICENSE +0 -21
  593. package/node_modules/is-electron/README.md +0 -25
  594. package/node_modules/is-electron/index.d.ts +0 -2
  595. package/node_modules/is-electron/index.js +0 -21
  596. package/node_modules/is-electron/package.json +0 -34
  597. package/node_modules/is-stream/index.d.ts +0 -79
  598. package/node_modules/is-stream/index.js +0 -28
  599. package/node_modules/is-stream/license +0 -9
  600. package/node_modules/is-stream/package.json +0 -42
  601. package/node_modules/is-stream/readme.md +0 -60
  602. package/node_modules/proxy-from-env/LICENSE +0 -20
  603. package/node_modules/proxy-from-env/README.md +0 -163
  604. package/node_modules/proxy-from-env/index.cjs +0 -105
  605. package/node_modules/proxy-from-env/index.js +0 -103
  606. package/node_modules/proxy-from-env/package.json +0 -43
  607. package/npm-shrinkwrap.json +0 -1467
@@ -1,2559 +0,0 @@
1
- <h3 align="center">💎 Platinum sponsors <br /></h3>
2
- <table align="center">
3
- <tr>
4
- <td align="center" width="50%">
5
- <a
6
- href="https://thanks.dev/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship"
7
- style="padding: 10px; display: inline-block"
8
- target="_blank"
9
- >
10
- <img
11
- width="90px"
12
- height="90px"
13
- src="https://images.opencollective.com/thanks-dev/360b917/logo/256.png?height=256"
14
- alt="Thanks.dev"
15
- />
16
- </a>
17
- <p
18
- align="center"
19
- >
20
- We're passionate about making open source sustainable. Scan your dependency tree to better understand which open source projects need funding.
21
- </p>
22
- <p align="center">
23
- <a
24
- href="https://thanks.dev/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship"
25
- target="_blank"
26
- ><b>thanks.dev</b></a
27
- >
28
- </p>
29
- </td>
30
- <td align="center" width="50%">
31
- <a
32
- href="https://opencollective.com/axios/contribute"
33
- target="_blank"
34
- >💜 Become a sponsor</a
35
- >
36
- </td>
37
- </tr>
38
- </table>
39
- <table align="center">
40
- <tr>
41
- <td align="center" width="50%">
42
- <a
43
- href="https://opencollective.com/axios/contribute"
44
- target="_blank"
45
- >💜 Become a sponsor</a
46
- >
47
- </td>
48
- <td align="center" width="50%">
49
- <a
50
- href="https://opencollective.com/axios/contribute"
51
- target="_blank"
52
- >💜 Become a sponsor</a
53
- >
54
- </td>
55
- </tr>
56
- </table>
57
- <h3 align="center">🥇 Gold sponsors <br /></h3>
58
- <table align="center" width="100%">
59
- <tr width="33.333333333333336%">
60
- <td align="center" width="33.333333333333336%">
61
- <a
62
- href="https://www.principal.com/about-us?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship"
63
- style="padding: 10px; display: inline-block"
64
- target="_blank"
65
- >
66
- <img
67
- width="90px"
68
- height="90px"
69
- src="https://images.opencollective.com/principal/431e690/logo.png"
70
- alt="Principal Financial Group"
71
- />
72
- </a>
73
- <p
74
- align="center"
75
- >
76
- Free tools to help with your financial planning needs!
77
- </p>
78
- <p align="center">
79
- <a
80
- href="https://www.principal.com/about-us?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship"
81
- target="_blank"
82
- ><b>principal.com</b></a
83
- >
84
- </p>
85
- </td>
86
- <td align="center" width="33.333333333333336%">
87
- <a
88
- href="https://opensource.sap.com?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship"
89
- style="padding: 10px; display: inline-block"
90
- target="_blank"
91
- >
92
- <img
93
- width="90px"
94
- height="90px"
95
- src="https://avatars.githubusercontent.com/u/2531208?s=200&v=4"
96
- alt="SAP"
97
- />
98
- </a>
99
- <p
100
- align="center"
101
- title="SAP SE, a global software company, is one of the largest vendors of ERP and other enterprise applications."
102
- >
103
- BSAP SE, a global software company, is one of the largest vendors of ERP and other enterprise applications.
104
- </p>
105
- <p align="center">
106
- <a
107
- href="https://opensource.sap.com?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship"
108
- target="_blank"
109
- ><b>opensource.sap.com</b></a
110
- >
111
- </p>
112
- </td>
113
- <td align="center" width="33.333333333333336%">
114
- <a
115
- href="https://www.descope.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship"
116
- style="padding: 10px; display: inline-block"
117
- target="_blank"
118
- >
119
- <img
120
- width="90px"
121
- height="90px"
122
- src="https://images.opencollective.com/descope/b53243e/logo.png"
123
- alt="Descope"
124
- />
125
- </a>
126
- <p
127
- align="center"
128
- title="Hi, we&#x27;re Descope! We are building something in the authentication space for app developers and can't wait to place it in your hands."
129
- >
130
- Reduce user friction, prevent account takeover, and get a 360° view of your customer and agentic identities with the Descope External IAM platform.
131
- </p>
132
- <p align="center">
133
- <a
134
- href="https://www.descope.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;referral&amp;utm_campaign&#x3D;axios-oss-sponsorship"
135
- target="_blank"
136
- ><b>descope.com</b></a
137
- >
138
- </p>
139
- </td>
140
- </tr>
141
- <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
- <td align="center" width="33.333333333333336%">
169
- <a
170
- href="https://rxdb.info/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship&utm_content=logo"
171
- style="padding: 10px; display: inline-block"
172
- target="_blank"
173
- >
174
- <img
175
- width="90px"
176
- height="90px"
177
- src="https://rxdb.info/files/logo/logo_text_white.svg"
178
- alt="RxDB"
179
- />
180
- </a>
181
- <p
182
- align="center"
183
- >
184
- RxDB is a NoSQL database for JavaScript that runs directly in your app.
185
- </p>
186
- <p align="center">
187
- <a
188
- href="https://rxdb.info/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship&utm_content=logo"
189
- target="_blank"
190
- ><b>rxdb.info</b></a
191
- >
192
- </p>
193
- </td>
194
- <td align="center" width="33.333333333333336%">
195
- <a
196
- href="https://poprey.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;sponsorlist&amp;utm_campaign&#x3D;sponsorship"
197
- style="padding: 10px; display: inline-block"
198
- target="_blank"
199
- >
200
- <img
201
- width="70px"
202
- height="70px"
203
- src="https://images.opencollective.com/instagram-likes/2a72a03/avatar.png"
204
- alt="Poprey"
205
- />
206
- </a>
207
- <p align="center">
208
- Buy Instagram Likes
209
- </p>
210
- <p align="center">
211
- <a
212
- href="https://poprey.com/?utm_source&#x3D;axios&amp;utm_medium&#x3D;readme_sponsorlist&amp;utm_campaign&#x3D;sponsorship"
213
- target="_blank"
214
- ><b>poprey.com</b></a
215
- >
216
- </p>
217
- </td>
218
- </tr>
219
- <tr width="33.333333333333336%">
220
- <td align="center" width="33.333333333333336%">
221
- <a
222
- href="https://buzzoid.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
223
- style="padding: 10px; display: inline-block"
224
- target="_blank"
225
- >
226
- <img
227
- width="71px"
228
- height="70px"
229
- src="https://images.opencollective.com/buzzoid-buy-instagram-followers/56a09fe/logo.png"
230
- alt="Buzzoid - Buy Instagram Followers"
231
- />
232
- </a>
233
- <p
234
- align="center"
235
- >
236
- At Buzzoid, you can buy Instagram followers through a short checkout flow with safety controls. Rated world&#39;s #1 IG service since 2012.
237
- </p>
238
- <p align="center">
239
- <a
240
- href="https://buzzoid.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
241
- target="_blank"
242
- ><b>buzzoid.com</b></a
243
- >
244
- </p>
245
- </td>
246
- <td align="center" width="33.333333333333336%">
247
- <a
248
- href="https://twicsy.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
249
- style="padding: 10px; display: inline-block"
250
- target="_blank"
251
- >
252
- <img
253
- width="71px"
254
- height="70px"
255
- src="https://images.opencollective.com/buy-instagram-followers-twicsy/b4c5d7f/logo/256.png?height=256"
256
- alt="Buy Instagram Followers Twicsy"
257
- />
258
- </a>
259
- <p
260
- align="center"
261
- >
262
- Buy real Instagram followers from Twicsy. Twicsy has been voted the best site to buy followers from the likes of US Magazine.
263
- </p>
264
- <p align="center">
265
- <a
266
- href="https://twicsy.com/buy-instagram-followers/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
267
- target="_blank"
268
- ><b>twicsy.com</b></a
269
- >
270
- </p>
271
- </td>
272
- <td align="center" width="33.333333333333336%">
273
- <a
274
- href="https://global.fun88.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
275
- style="padding: 10px; display: inline-block"
276
- target="_blank"
277
- >
278
- <img
279
- width="71px"
280
- height="70px"
281
- src="https://images.opencollective.com/fun88-official/bf2843c/logo.png"
282
- alt="Fun 88"
283
- />
284
- </a>
285
- <p
286
- align="center"
287
- >
288
- 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.
289
- </p>
290
- <p align="center">
291
- <a
292
- href="https://global.fun88.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
293
- target="_blank"
294
- ><b>global.fun88.com</b></a
295
- >
296
- </p>
297
- </td>
298
- </tr>
299
- </table>
300
-
301
- <!--<div>marker</div>-->
302
-
303
- <br><br>
304
-
305
- <div align="center">
306
- <a href="https://axios.rest"><img src="https://axios.rest/logo.svg" alt="Axios" /></a><br>
307
- </div>
308
-
309
- <p align="center">Promise based HTTP client for the browser and node.js</p>
310
-
311
- <p align="center">
312
- <a href="https://axios.rest/"><b>Website</b></a> •
313
- <a href="https://axios.rest/pages/getting-started/first-steps.html"><b>Documentation</b></a>
314
- </p>
315
-
316
- <div align="center">
317
-
318
- [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
319
- [![Build status](https://img.shields.io/github/actions/workflow/status/axios/axios/ci.yml?branch=v1.x&label=CI&logo=github&style=flat-square)](https://github.com/axios/axios/actions/workflows/ci.yml)
320
- [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/axios/axios)
321
- [![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=axios&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=axios)
322
- [![npm bundle size](https://img.shields.io/bundlephobia/minzip/axios?style=flat-square)](https://bundlephobia.com/package/axios@latest)
323
- [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](https://npm-stat.com/charts.html?package=axios)
324
- [![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios)
325
- [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
326
- [![Contributors](https://img.shields.io/github/contributors/axios/axios.svg?style=flat-square)](CONTRIBUTORS.md)
327
- [![Agent Friendly](https://agentfriendlycode.com/api/badge/github/axios/axios.svg)](https://agentfriendlycode.com/repo/32)
328
-
329
- </div>
330
-
331
- ## Table of contents
332
-
333
- - [Features](#features)
334
- - [Browser support](#browser-support)
335
- - [Installing](#installing)
336
- - [Package manager](#package-manager)
337
- - [CDN](#cdn)
338
- - [Example](#example)
339
- - [Axios API](#axios-api)
340
- - [Request method aliases](#request-method-aliases)
341
- - [Concurrency](#concurrency-deprecated)
342
- - [Creating an instance](#creating-an-instance)
343
- - [Instance methods](#instance-methods)
344
- - [Request config](#request-config)
345
- - [Response schema](#response-schema)
346
- - [Config defaults](#config-defaults)
347
- - [Global axios defaults](#global-axios-defaults)
348
- - [Custom instance defaults](#custom-instance-defaults)
349
- - [Config order of precedence](#config-order-of-precedence)
350
- - [Interceptors](#interceptors)
351
- - [Multiple interceptors](#multiple-interceptors)
352
- - [Handling errors](#handling-errors)
353
- - [Handling timeouts](#handling-timeouts)
354
- - [Cancellation](#cancellation)
355
- - [AbortController](#abortcontroller)
356
- - [CancelToken](#canceltoken-deprecated)
357
- - [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format)
358
- - [URLSearchParams](#urlsearchparams)
359
- - [Query string](#query-string-older-browsers)
360
- - [Automatic serialization](#automatic-serialization-to-urlsearchparams)
361
- - [Using multipart/form-data format](#using-multipartform-data-format)
362
- - [FormData](#formdata)
363
- - [Automatic serialization](#automatic-serialization-to-formdata)
364
- - [Posting files](#posting-files)
365
- - [HTML form posting](#html-form-posting-browser)
366
- - [Progress capturing](#progress-capturing)
367
- - [Rate limiting](#rate-limiting)
368
- - [AxiosHeaders](#axiosheaders)
369
- - [Fetch adapter](#fetch-adapter)
370
- - [Custom fetch](#custom-fetch)
371
- - [Using with Tauri](#using-with-tauri)
372
- - [Using with SvelteKit](#using-with-sveltekit)
373
- - [HTTP/2 support](#http2-support)
374
- - [Semver](#semver)
375
- - [Promises](#promises)
376
- - [TypeScript](#typescript)
377
- - [Contributing](#contributing)
378
- - [Local setup](#local-setup)
379
- - [Resources](#resources)
380
- - [Credits](#credits)
381
- - [License](#license)
382
-
383
- ## Features
384
-
385
- - Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser.
386
- - Make [http](https://nodejs.org/api/http.html) requests from Node.js.
387
- - Use the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API for asynchronous request handling.
388
- - Intercept requests and responses to add custom logic or transform data.
389
- - Transform request and response data.
390
- - Cancel requests with built-in cancellation APIs.
391
- - Serialize and parse [JSON](https://www.json.org/json-en.html) data.
392
- - Serialize data objects to `multipart/form-data` or `application/x-www-form-urlencoded`.
393
- - Add client-side protection against [Cross-Site Request Forgery](https://en.wikipedia.org/wiki/Cross-site_request_forgery).
394
-
395
- ## Browser support
396
-
397
- | Chrome | Firefox | Safari | Opera | Edge |
398
- | :------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------: |
399
- | ![Chrome browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge browser logo](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) |
400
- | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
401
-
402
- [![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios)
403
-
404
- ## Installing
405
-
406
- ### Package manager
407
-
408
- Using npm:
409
-
410
- ```bash
411
- $ npm install axios
412
- ```
413
-
414
- Using yarn:
415
-
416
- ```bash
417
- $ yarn add axios
418
- ```
419
-
420
- Using pnpm:
421
-
422
- ```bash
423
- $ pnpm add axios
424
- ```
425
-
426
- Using bun:
427
-
428
- ```bash
429
- $ bun add axios
430
- ```
431
-
432
- Using Deno:
433
-
434
- ```bash
435
- $ deno add axios
436
- ```
437
-
438
- Once the package is installed, import it with `import` or `require`:
439
-
440
- ```js
441
- import axios, { isCancel, AxiosError } from 'axios';
442
- ```
443
-
444
- You can also use the default export, since the named export is just a re-export from the Axios factory:
445
-
446
- ```js
447
- import axios from 'axios';
448
-
449
- console.log(axios.isCancel('something'));
450
- ```
451
-
452
- If you use `require` for importing, **only the default export is available**:
453
-
454
- ```js
455
- const axios = require('axios');
456
-
457
- console.log(axios.isCancel('something'));
458
- ```
459
-
460
- Some bundlers and ES6 linters need this form:
461
-
462
- ```js
463
- import { default as axios } from 'axios';
464
- ```
465
-
466
- In custom or legacy environments, you can import the bundle directly:
467
-
468
- ```js
469
- const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017)
470
- // const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017)
471
- ```
472
-
473
- ### CDN
474
-
475
- Using jsDelivr CDN (ES5 UMD browser module):
476
-
477
- ```html
478
- <script src="https://cdn.jsdelivr.net/npm/axios@1.13.2/dist/axios.min.js"></script>
479
- ```
480
-
481
- Using unpkg CDN:
482
-
483
- ```html
484
- <script src="https://unpkg.com/axios@1.13.2/dist/axios.min.js"></script>
485
- ```
486
-
487
- ## Example
488
-
489
- ```js
490
- import axios from 'axios';
491
- //const axios = require('axios'); // legacy way
492
-
493
- try {
494
- const response = await axios.get('/user?ID=12345');
495
- console.log(response);
496
- } catch (error) {
497
- console.error(error);
498
- }
499
-
500
- // Optionally the request above could also be done as
501
- axios
502
- .get('/user', {
503
- params: {
504
- ID: 12345,
505
- },
506
- timeout: 5000, // 5 seconds. See "Handling Timeouts" below for matching error handling
507
- })
508
- .then(function (response) {
509
- console.log(response);
510
- })
511
- .catch(function (error) {
512
- console.log(error);
513
- })
514
- .finally(function () {
515
- // always executed
516
- });
517
-
518
- // Want to use async/await? Add the `async` keyword to your outer function/method.
519
- async function getUser() {
520
- try {
521
- // Example: GET request with query parameters
522
- const response = await axios.get('/user', {
523
- params: {
524
- ID: 12345,
525
- },
526
- });
527
-
528
- // Using the `params` option improves readability and automatically formats query strings
529
-
530
- console.log(response);
531
- } catch (error) {
532
- console.error(error);
533
- }
534
- }
535
- ```
536
-
537
- > Note: Set a `timeout` in production. Without one, a stalled request can hang
538
- > indefinitely. See [Handling Timeouts](#handling-timeouts) for the matching error handling.
539
-
540
- > Note: `async/await` is part of ECMAScript 2017 and is not supported in Internet
541
- > Explorer and older browsers, so use with caution.
542
-
543
- Performing a `POST` request
544
-
545
- ```js
546
- const response = await axios.post('/user', {
547
- firstName: 'Fred',
548
- lastName: 'Flintstone',
549
- });
550
- console.log(response);
551
- ```
552
-
553
- Performing multiple concurrent requests
554
-
555
- ```js
556
- function getUserAccount() {
557
- return axios.get('/user/12345');
558
- }
559
-
560
- function getUserPermissions() {
561
- return axios.get('/user/12345/permissions');
562
- }
563
-
564
- Promise.all([getUserAccount(), getUserPermissions()]).then(function (results) {
565
- const acct = results[0];
566
- const perm = results[1];
567
- });
568
- ```
569
-
570
- ## axios API
571
-
572
- Requests can be made by passing the relevant config to `axios`.
573
-
574
- ##### axios(config)
575
-
576
- ```js
577
- // Send a POST request
578
- axios({
579
- method: 'post',
580
- url: '/user/12345',
581
- data: {
582
- firstName: 'Fred',
583
- lastName: 'Flintstone',
584
- },
585
- });
586
- ```
587
-
588
- ```js
589
- // GET request for remote image in node.js
590
- const response = await axios({
591
- method: 'get',
592
- url: 'https://bit.ly/2mTM3nY',
593
- responseType: 'stream',
594
- });
595
- response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'));
596
- ```
597
-
598
- ##### axios(url[, config])
599
-
600
- ```js
601
- // Send a GET request (default method)
602
- axios('/user/12345');
603
- ```
604
-
605
- ### Request method aliases
606
-
607
- For convenience, aliases have been provided for all common request methods.
608
-
609
- ##### axios.request(config)
610
-
611
- ##### axios.get(url[, config])
612
-
613
- ##### axios.delete(url[, config])
614
-
615
- ##### axios.head(url[, config])
616
-
617
- ##### axios.options(url[, config])
618
-
619
- ##### axios.post(url[, data[, config]])
620
-
621
- ##### axios.put(url[, data[, config]])
622
-
623
- ##### axios.patch(url[, data[, config]])
624
-
625
- ###### Note
626
-
627
- When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config.
628
-
629
- ### Concurrency (deprecated)
630
-
631
- Use `Promise.all` instead of these helpers.
632
-
633
- Helper functions for dealing with concurrent requests.
634
-
635
- axios.all(iterable)
636
- axios.spread(callback)
637
-
638
- ### Creating an instance
639
-
640
- You can create a new instance of axios with a custom config.
641
-
642
- ##### axios.create([config])
643
-
644
- ```js
645
- const instance = axios.create({
646
- baseURL: 'https://some-domain.com/api/',
647
- timeout: 1000,
648
- headers: { 'X-Custom-Header': 'foobar' },
649
- });
650
- ```
651
-
652
- ### Instance methods
653
-
654
- The following instance methods are available. Axios merges the specified config with the instance config.
655
-
656
- ##### axios#request(config)
657
-
658
- ##### axios#get(url[, config])
659
-
660
- ##### axios#delete(url[, config])
661
-
662
- ##### axios#head(url[, config])
663
-
664
- ##### axios#options(url[, config])
665
-
666
- ##### axios#post(url[, data[, config]])
667
-
668
- ##### axios#put(url[, data[, config]])
669
-
670
- ##### axios#patch(url[, data[, config]])
671
-
672
- ##### axios#getUri([config])
673
-
674
- ## Request config
675
-
676
- ### Security notice: decompression-bomb protection is opt-in
677
-
678
- By default `maxContentLength` and `maxBodyLength` are `-1` (unlimited). A malicious or compromised server can return a tiny gzip/deflate/brotli/zstd body that expands to gigabytes and exhaust the Node.js process.
679
-
680
- If you call servers you do not fully trust, **set a cap**:
681
-
682
- ```js
683
- axios.defaults.maxContentLength = 10 * 1024 * 1024; // 10 MB
684
- axios.defaults.maxBodyLength = 10 * 1024 * 1024;
685
- ```
686
-
687
- See the [security guide](https://axios.rest/pages/misc/security.html) for details.
688
-
689
- These config options are available for requests. Only `url` is required. Requests default to `GET` when `method` is not set.
690
-
691
- ```js
692
- {
693
- // `url` is the server URL for the request
694
- url: '/user',
695
-
696
- // `method` is the request method to be used when making the request
697
- method: 'get', // default
698
-
699
- // Axios prepends `baseURL` to `url` unless `url` is absolute and `allowAbsoluteUrls` is set to true.
700
- // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
701
- // to the methods of that instance.
702
- baseURL: 'https://some-domain.com/api/',
703
-
704
- // `allowAbsoluteUrls` determines whether or not absolute URLs will override a configured `baseUrl`.
705
- // When set to true (default), absolute values for `url` will override `baseUrl`.
706
- // When set to false, absolute values for `url` will always be prepended by `baseUrl`.
707
- allowAbsoluteUrls: true,
708
-
709
- // `transformRequest` allows changes to the request data before it is sent to the server
710
- // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE'
711
- // The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
712
- // FormData or Stream
713
- // You may modify the headers object.
714
- transformRequest: [function (data, headers) {
715
- // Do whatever you want to transform the data
716
-
717
- return data;
718
- }],
719
-
720
- // `transformResponse` allows changes to the response data to be made before
721
- // it is passed to then/catch
722
- transformResponse: [function (data) {
723
- // Do whatever you want to transform the data
724
-
725
- return data;
726
- }],
727
-
728
- // `parseReviver` is an optional function passed as the
729
- // second argument (reviver) to JSON.parse()
730
- parseReviver: function (key, value, context) {
731
- // In modern environments, context.source provides the raw JSON string
732
- // allowing for precision-safe parsing of BigInt
733
- if (typeof value === 'number' && context?.source) {
734
- const isInteger = Number.isInteger(value);
735
- const isUnsafe = !Number.isSafeInteger(value);
736
- const isValidIntegerString = /^-?\d+$/.test(context.source);
737
-
738
- if (isInteger && isUnsafe && isValidIntegerString) {
739
- try {
740
- return BigInt(context.source);
741
- } catch {
742
- // Fallback: return original value if parsing fails
743
- }
744
- }
745
- }
746
- return value;
747
- },
748
-
749
- // `headers` are custom headers to be sent
750
- headers: {'X-Requested-With': 'XMLHttpRequest'},
751
-
752
- // `params` are the URL parameters to be sent with the request
753
- // Must be a plain object or a URLSearchParams object
754
- params: {
755
- ID: 12345
756
- },
757
-
758
- // `paramsSerializer` is an optional config that allows you to customize serializing `params`.
759
- paramsSerializer: {
760
-
761
- // Custom encoder function which sends key/value pairs in an iterative fashion.
762
- encode?: (param: string): string => { /* Do custom operations here and return transformed string */ },
763
-
764
- // Custom serializer function for the entire parameter. Allows the user to mimic pre 1.x behaviour.
765
- serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ),
766
-
767
- // Configuration for formatting array indexes in the params.
768
- indexes: false, // Three available options: (1) indexes: null (leads to no brackets), (2) (default) indexes: false (leads to empty brackets), (3) indexes: true (leads to brackets with indexes).
769
-
770
- // Maximum object nesting depth when serializing params. Payloads deeper than this throw an
771
- // AxiosError with code ERR_FORM_DATA_DEPTH_EXCEEDED. Default: 100. Set to Infinity to disable.
772
- maxDepth: 100
773
-
774
- },
775
-
776
- // `data` is the data to be sent as the request body
777
- // Only applicable for request methods 'PUT', 'POST', 'DELETE', and 'PATCH'
778
- // `data` is request-specific: axios does not inherit or deep-merge it from defaults.
779
- // To add shared body fields, use a request interceptor or transformRequest.
780
- // When no `transformRequest` is set, it must be of one of the following types:
781
- // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
782
- // - Browser only: FormData, File, Blob
783
- // - React Native: FormData
784
- // - Node only: Stream, Buffer, FormData (form-data package)
785
- data: {
786
- firstName: 'Fred'
787
- },
788
-
789
- // `formDataHeaderPolicy` controls how node.js FormData#getHeaders() is copied.
790
- // 'legacy' (default) copies all returned headers for v1 compatibility.
791
- // 'content-only' copies only Content-Type and Content-Length.
792
- formDataHeaderPolicy: 'legacy',
793
-
794
- // syntax alternative to send data into the body
795
- // method post
796
- // only the value is sent, not the key
797
- data: 'Country=Brasil&City=Belo Horizonte',
798
-
799
- // `timeout` specifies the number of milliseconds before the request times out.
800
- // If the request takes longer than `timeout`, Axios aborts it.
801
- timeout: 1000, // default is `0` (no timeout)
802
-
803
- // `withCredentials` indicates whether or not cross-site Access-Control requests
804
- // should be made using credentials
805
- // This only controls whether the browser sends credentials.
806
- // It does not control whether the XSRF header is added.
807
- withCredentials: false, // default
808
-
809
- // `adapter` allows custom handling of requests which makes testing easier.
810
- // Return a promise and supply a valid response (see lib/adapters/README.md)
811
- adapter: function (config) {
812
- /* ... */
813
- },
814
- // Also, you can set the name of the built-in adapter, or provide an array with their names
815
- // to choose the first available in the environment
816
- adapter: 'xhr', // 'fetch' | 'http' | ['xhr', 'http', 'fetch']
817
-
818
- // `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
819
- // This will set an `Authorization` header, overwriting any existing
820
- // `Authorization` custom headers you have set using `headers`.
821
- // If `auth` is omitted, the Node.js HTTP and fetch adapters can read
822
- // HTTP Basic auth credentials from the request URL, for example
823
- // `https://user:pass@example.com`. Axios decodes percent-encoded URL
824
- // credentials, and `auth` takes precedence over URL-embedded credentials.
825
- // The Node.js HTTP adapter preserves Basic auth on same-origin redirects
826
- // and strips it on cross-origin redirects.
827
- // Please note that only HTTP Basic auth is configurable through this parameter.
828
- // For Bearer tokens and such, use `Authorization` custom headers instead.
829
- auth: {
830
- username: 'janedoe',
831
- password: 's00pers3cret'
832
- },
833
-
834
- // `responseType` indicates the type of data that the server will respond with
835
- // options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
836
- // browser only: 'blob'
837
- responseType: 'json', // default
838
-
839
- // `responseEncoding` indicates encoding to use for decoding responses (Node.js only)
840
- // Note: Ignored for `responseType` of 'stream' or client-side requests
841
- // options are: 'ascii', 'ASCII', 'ansi', 'ANSI', 'binary', 'BINARY', 'base64', 'BASE64', 'base64url',
842
- // 'BASE64URL', 'hex', 'HEX', 'latin1', 'LATIN1', 'ucs-2', 'UCS-2', 'ucs2', 'UCS2', 'utf-8', 'UTF-8',
843
- // 'utf8', 'UTF8', 'utf16le', 'UTF16LE'
844
- responseEncoding: 'utf8', // default
845
-
846
- // `xsrfCookieName` is the name of the cookie to use as a value for the xsrf token
847
- xsrfCookieName: 'XSRF-TOKEN', // default
848
-
849
- // `xsrfHeaderName` is the name of the http header that carries the xsrf token value
850
- xsrfHeaderName: 'X-XSRF-TOKEN', // default
851
-
852
- // `withXSRFToken` defines whether to send the XSRF header in browser requests.
853
- // `undefined` (default) - set XSRF header only for the same origin requests
854
- // `true` - always set XSRF header, including for cross-origin requests
855
- // `false` - never set XSRF header
856
- // function - resolve with custom logic; receives the internal config object
857
- withXSRFToken: boolean | undefined | ((config: InternalAxiosRequestConfig) => boolean | undefined),
858
-
859
- // `withXSRFToken` controls whether Axios reads the XSRF cookie and sets the XSRF header.
860
- // - `undefined` (default): the XSRF header is set only for same-origin requests.
861
- // - `true`: attempt to set the XSRF header for all requests (including cross-origin).
862
- // - `false`: never set the XSRF header.
863
- // - function: a callback that receives the request `config` and returns `true`,
864
- // `false`, or `undefined` to decide per-request behavior.
865
- //
866
- // Note about `withCredentials`: `withCredentials` controls whether cross-site
867
- // requests include credentials (cookies and HTTP auth). In older Axios versions,
868
- // setting `withCredentials: true` implicitly caused Axios to set the XSRF header
869
- // for cross-origin requests. Newer Axios separates these concerns: to allow the
870
- // XSRF header to be sent for cross-origin requests you should set both
871
- // `withCredentials: true` and `withXSRFToken: true`.
872
- //
873
- // Example:
874
- // axios.get('/user', { withCredentials: true, withXSRFToken: true });
875
-
876
- // `onUploadProgress` allows handling of progress events for uploads
877
- // browser & node.js
878
- onUploadProgress: function ({loaded, total, progress, bytes, estimated, rate, upload = true}) {
879
- // Do whatever you want with the Axios progress event
880
- },
881
-
882
- // `onDownloadProgress` allows handling of progress events for downloads
883
- // browser & node.js
884
- onDownloadProgress: function ({loaded, total, progress, bytes, estimated, rate, download = true}) {
885
- // Do whatever you want with the Axios progress event
886
- },
887
-
888
- // `maxContentLength` defines the max size of the response content in bytes.
889
- // It is enforced by the Node.js HTTP adapter and the fetch adapter.
890
- maxContentLength: 2000,
891
-
892
- // `maxBodyLength` defines the max size of the request content in bytes.
893
- // It is enforced by the Node.js HTTP adapter and the fetch adapter when the body length can be determined.
894
- maxBodyLength: 2000,
895
-
896
- // `redact` masks matching config keys when AxiosError#toJSON() is called.
897
- // Matching is case-insensitive and recursive. It does not change the request.
898
- redact: ['authorization', 'password'],
899
-
900
- // `validateStatus` defines whether to resolve or reject the promise for a given
901
- // HTTP response status code. If `validateStatus` returns `true` or is set to
902
- // `null`, Axios resolves the promise; otherwise, Axios rejects it.
903
- // Explicit `validateStatus: undefined` resolves every status by default for
904
- // backward compatibility. Set `transitional.validateStatusUndefinedResolves`
905
- // to `false` to make explicit `undefined` behave as if this option was omitted.
906
- validateStatus: function (status) {
907
- return status >= 200 && status < 300; // default
908
- },
909
-
910
- // `maxRedirects` defines the maximum number of redirects to follow in node.js.
911
- // If set to 0, Axios follows no redirects.
912
- maxRedirects: 21, // default
913
-
914
- // `sensitiveHeaders` (Node only option) lists custom secret-bearing headers
915
- // (such as `X-API-Key`) to remove from cross-origin redirects. Matching is
916
- // case-insensitive. Same-origin redirects keep these headers. If
917
- // `maxRedirects` is 0, this option is not used.
918
- sensitiveHeaders: ['X-API-Key'],
919
-
920
- // `beforeRedirect` defines a function that Axios calls before redirect.
921
- // Use this to adjust the request options upon redirecting,
922
- // to inspect the latest response headers,
923
- // or to cancel the request by throwing an error
924
- // If maxRedirects is set to 0, `beforeRedirect` is not used.
925
-
926
- beforeRedirect: (options, { headers }) => {
927
- if (
928
- options.hostname === "example.com" &&
929
- options.protocol === "https:"
930
- ) {
931
- options.auth = "user:password";
932
- }
933
- },
934
- // Security note:
935
- // The `beforeRedirect` hook runs after sensitive headers are stripped during redirects.
936
- // `follow-redirects` removes credentials on protocol downgrades
937
- // (HTTPS to HTTP). Because `beforeRedirect` runs after that step,
938
- // re-injecting credentials without checking the destination can expose
939
- // sensitive data. Only add credentials for trusted HTTPS destinations.
940
-
941
- // `socketPath` defines a UNIX Socket to be used in node.js.
942
- // e.g. '/var/run/docker.sock' to send requests to the docker daemon.
943
- // Only either `socketPath` or `proxy` can be specified.
944
- // If both are specified, `socketPath` is used.
945
- //
946
- // Security: when `socketPath` is set, hostname/port of the URL are ignored,
947
- // which bypasses hostname-based SSRF protections. Never derive `socketPath`
948
- // from untrusted input. Use `allowedSocketPaths` (below) to restrict accepted
949
- // socket paths for defense-in-depth.
950
- socketPath: null, // default
951
-
952
- // `allowedSocketPaths` restricts which `socketPath` values are accepted.
953
- // Accepts a string or array of strings. Entries and the incoming socketPath
954
- // are compared after path.resolve(). A mismatch throws AxiosError with code
955
- // `ERR_BAD_OPTION_VALUE`. When null/undefined, no restriction is applied.
956
- allowedSocketPaths: null, // default
957
-
958
- // `transport` determines the transport method for the request.
959
- // If defined, Axios uses it. Otherwise, if `maxRedirects` is 0,
960
- // Axios uses the default `http` or `https` library, depending on the protocol specified in `protocol`.
961
- // Otherwise, Axios uses the `httpFollow` or `httpsFollow` library, again depending on the protocol,
962
- // which can handle redirects.
963
- transport: undefined, // default
964
-
965
- // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
966
- // and https requests, respectively, in node.js. This allows options to be added like
967
- // `keepAlive` that are not enabled by default before Node.js v19.0.0. After Node.js
968
- // v19.0.0, you no longer need to customize the agent to enable `keepAlive` because
969
- // `http.globalAgent` has `keepAlive` enabled by default.
970
- httpAgent: new http.Agent({ keepAlive: true }),
971
- httpsAgent: new https.Agent({ keepAlive: true }),
972
-
973
- // `proxy` defines the hostname, port, and protocol of the proxy server.
974
- // You can also define your proxy using the conventional `http_proxy` and
975
- // `https_proxy` environment variables. If you are using environment variables
976
- // for your proxy configuration, you can also define a `no_proxy` environment
977
- // variable as a comma-separated list of domains that should not be proxied.
978
- // Use `false` to disable proxies, ignoring environment variables.
979
- // On Node.js versions with native environment proxy support, axios defers
980
- // environment proxy handling to Node when the selected agent has `proxyEnv`
981
- // enabled, including processes started with `NODE_USE_ENV_PROXY=1`,
982
- // `--use-env-proxy`, or `NODE_OPTIONS=--use-env-proxy`. Custom agents without
983
- // `proxyEnv` continue to use axios environment proxy resolution. Explicit
984
- // `proxy` config is still handled by axios.
985
- // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
986
- // supplies credentials.
987
- // For `http://` targets, axios sends the request to the proxy in
988
- // forward-proxy mode and stamps `Proxy-Authorization` onto the request
989
- // headers (overwriting any user-supplied `Proxy-Authorization` header).
990
- // For `https://` targets, axios establishes a CONNECT tunnel through the
991
- // proxy and performs TLS end-to-end with the origin; `Proxy-Authorization`
992
- // is sent on the CONNECT request only, never on the wrapped TLS request,
993
- // so the proxy never sees the URL, headers, or body. Axios forwards
994
- // `httpsAgent` TLS options such as `ca`, `cert`, `key`, and
995
- // `rejectUnauthorized` to the generated tunneling agent, so they still apply
996
- // to the origin TLS connection.
997
- // If you supply an `HttpsProxyAgent`, axios leaves tunneling to that agent.
998
- // If the proxy server uses HTTPS, then you must set the protocol to `https`.
999
- // A user-supplied `Host` header in `headers` is preserved when forwarding
1000
- // through a proxy (case-insensitive match on `host`/`Host`/`HOST`); this
1001
- // lets you target a virtual host that differs from the request URL, for
1002
- // example, hitting `127.0.0.1:4000` while having the proxy treat the
1003
- // request as `example.com`. If no `Host` header is supplied, axios
1004
- // defaults it to the request URL's `hostname:port` as before. The Host
1005
- // header is only set in forward-proxy mode (HTTP targets); for HTTPS
1006
- // tunneling the Host header is sent inside the TLS connection, not seen
1007
- // by the proxy.
1008
- proxy: {
1009
- protocol: 'https',
1010
- host: '127.0.0.1',
1011
- // hostname: '127.0.0.1' // Takes precedence over 'host' if both are defined
1012
- port: 9000,
1013
- auth: {
1014
- username: 'mikeymike',
1015
- password: 'rapunz3l'
1016
- }
1017
- },
1018
-
1019
- // `cancelToken` specifies a cancel token that can be used to cancel the request
1020
- // (see Cancellation section below for details)
1021
- cancelToken: new CancelToken(function (cancel) {
1022
- }),
1023
-
1024
- // an alternative way to cancel Axios requests using AbortController
1025
- signal: new AbortController().signal,
1026
-
1027
- // `decompress` indicates whether or not the response body should be decompressed
1028
- // automatically. If set to `true` will also remove the 'content-encoding' header
1029
- // from the responses objects of all decompressed responses
1030
- // Axios supports gzip, deflate, brotli, and zstd when the current Node.js
1031
- // runtime provides the corresponding zlib decompressor.
1032
- // - Node only (XHR cannot turn off decompression)
1033
- decompress: true, // default
1034
-
1035
- // `insecureHTTPParser` boolean.
1036
- // Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers.
1037
- // This may allow interoperability with non-conformant HTTP implementations.
1038
- // Using the insecure parser should be avoided.
1039
- // see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback
1040
- // see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none
1041
- insecureHTTPParser: undefined, // default
1042
-
1043
- // transitional options for backward compatibility that may be removed in the newer versions
1044
- transitional: {
1045
- // silent JSON parsing mode
1046
- // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)
1047
- // `false` - throw SyntaxError if JSON parsing failed
1048
- // Important: this option only takes effect when `responseType` is explicitly set to 'json'.
1049
- // When `responseType` is omitted (defaults to no value), axios uses `forcedJSONParsing`
1050
- // to attempt JSON parsing, but will silently return the raw string on failure regardless
1051
- // of this setting. To have invalid JSON throw errors, use:
1052
- // { responseType: 'json', transitional: { silentJSONParsing: false } }
1053
- silentJSONParsing: true, // default value for the current Axios version
1054
-
1055
- // try to parse the response string as JSON even if `responseType` is not 'json'
1056
- forcedJSONParsing: true,
1057
-
1058
- // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
1059
- clarifyTimeoutError: false,
1060
-
1061
- // keep explicit `validateStatus: undefined` resolving every response status
1062
- // for backward compatibility. Set to false to make explicit undefined behave
1063
- // as if validateStatus was omitted.
1064
- validateStatusUndefinedResolves: true,
1065
-
1066
- // advertise `zstd` in the default Accept-Encoding header when the current
1067
- // Node.js runtime supports zstd decompression. Axios still decompresses
1068
- // zstd responses when support exists and `decompress` is true.
1069
- advertiseZstdAcceptEncoding: false,
1070
-
1071
- // use the legacy interceptor request/response ordering
1072
- legacyInterceptorReqResOrdering: true, // default
1073
- },
1074
-
1075
- env: {
1076
- // The FormData class to be used to automatically serialize the payload into a FormData object
1077
- FormData: window?.FormData || global?.FormData
1078
- },
1079
-
1080
- formSerializer: {
1081
- visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form values
1082
- dots: boolean; // use dots instead of brackets format
1083
- metaTokens: boolean; // keep special endings like {} in parameter key
1084
- indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes
1085
- maxDepth: 100; // maximum object nesting depth; throws AxiosError (ERR_FORM_DATA_DEPTH_EXCEEDED) if exceeded. Set to Infinity to disable.
1086
- },
1087
-
1088
- // http adapter only (node.js)
1089
- maxRate: [
1090
- 100 * 1024, // 100KB/s upload limit,
1091
- 100 * 1024 // 100KB/s download limit
1092
- ]
1093
- }
1094
- ```
1095
-
1096
- For custom secret-bearing headers in Node.js, list them in `sensitiveHeaders` so Axios removes them when following a redirect to another origin:
1097
-
1098
- ```js
1099
- axios.get('https://api.example.com/users', {
1100
- headers: { 'X-API-Key': 'secret' },
1101
- sensitiveHeaders: ['X-API-Key'],
1102
- });
1103
- ```
1104
-
1105
- ### Strict RFC 3986 percent-encoding for query params
1106
-
1107
- By default, axios decodes `%3A`, `%24`, `%2C` and `%20` back to `:`, `$`, `,` and `+` for readability (the `+` follows the `application/x-www-form-urlencoded` convention for spaces in query strings). These characters are valid in a query component under [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.4), so the default output is correct, but some backends require strict percent-encoding and reject the readable form.
1108
-
1109
- Override the default encoder via `paramsSerializer.encode`:
1110
-
1111
- ```js
1112
- // Per-request: emit strict RFC 3986 percent-encoding for query values
1113
- axios.get('/foo', {
1114
- params: { filter: JSON.stringify({ startedAt: '2026-01-23' }) },
1115
- paramsSerializer: { encode: encodeURIComponent },
1116
- });
1117
-
1118
- // Or set it on the instance defaults
1119
- const client = axios.create({
1120
- paramsSerializer: { encode: encodeURIComponent },
1121
- });
1122
- ```
1123
-
1124
- ## HTTP/2 support
1125
-
1126
- Axios has experimental HTTP/2 support in the Node.js HTTP adapter.
1127
-
1128
- Support depends on the runtime environment and Node.js version. Redirects and some adapter behavior may differ from HTTP/1.1.
1129
-
1130
- Options like `httpVersion` and `http2Options` are adapter-specific and may not work the same way in every environment.
1131
-
1132
- If you need HTTP/2, check runtime support or use a custom adapter.
1133
-
1134
- ## Response schema
1135
-
1136
- The response to a request contains the following information.
1137
-
1138
- ```js
1139
- {
1140
- // `data` is the response that was provided by the server
1141
- data: {},
1142
-
1143
- // `status` is the HTTP status code from the server response
1144
- status: 200,
1145
-
1146
- // `statusText` is the HTTP status message from the server response
1147
- statusText: 'OK',
1148
-
1149
- // `headers` the HTTP headers that the server responded with
1150
- // All header names are lowercase and can be accessed using the bracket notation.
1151
- // Example: `response.headers['content-type']`
1152
- headers: {},
1153
-
1154
- // `config` is the config that was provided to `axios` for the request
1155
- config: {},
1156
-
1157
- // `request` is the request that generated this response
1158
- // It is the last ClientRequest instance in node.js (in redirects)
1159
- // and an XMLHttpRequest instance in the browser
1160
- request: {}
1161
- }
1162
- ```
1163
-
1164
- When using `then`, you receive the response like this:
1165
-
1166
- ```js
1167
- const response = await axios.get('/user/12345');
1168
- console.log(response.data);
1169
- console.log(response.status);
1170
- console.log(response.statusText);
1171
- console.log(response.headers);
1172
- console.log(response.config);
1173
- ```
1174
-
1175
- When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as the second parameter of `then`, read the response from the `error` object. See [Handling errors](#handling-errors).
1176
-
1177
- ## Config defaults
1178
-
1179
- Config defaults apply to every request.
1180
-
1181
- ### Global axios defaults
1182
-
1183
- ```js
1184
- axios.defaults.baseURL = 'https://api.example.com';
1185
-
1186
- // Important: If you use axios with multiple domains, Axios sends AUTH_TOKEN to all of them.
1187
- // See below for an example using Custom instance defaults instead.
1188
- axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
1189
-
1190
- axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
1191
- ```
1192
-
1193
- ### Custom instance defaults
1194
-
1195
- ```js
1196
- // Set config defaults when creating the instance
1197
- const instance = axios.create({
1198
- baseURL: 'https://api.example.com',
1199
- });
1200
-
1201
- // Alter defaults after instance has been created
1202
- instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
1203
- ```
1204
-
1205
- ### Config order of precedence
1206
-
1207
- Axios merges config in this order: library defaults from [lib/defaults/index.js](https://github.com/axios/axios/blob/main/lib/defaults/index.js#L49), the instance `defaults` property, and the request `config` argument. Later values take precedence over earlier ones.
1208
-
1209
- Some options are request-specific and are only taken from the request `config`. `data` is one of those options: axios does not inherit or deep-merge request bodies from global or instance defaults. If every request needs shared body fields, add them with a request interceptor or `transformRequest`, and scope that logic carefully so sensitive values are not sent to the wrong endpoint.
1210
-
1211
- ```js
1212
- // Create an instance using the config defaults provided by the library
1213
- // At this point the timeout config value is `0` as is the default for the library
1214
- const instance = axios.create();
1215
-
1216
- // Override timeout default for the library
1217
- // Now all requests using this instance will wait 2.5 seconds before timing out
1218
- instance.defaults.timeout = 2500;
1219
-
1220
- // Override timeout for this request as it's known to take a long time
1221
- instance.get('/longRequest', {
1222
- timeout: 5000,
1223
- });
1224
- ```
1225
-
1226
- ## Interceptors
1227
-
1228
- You can intercept requests or responses before methods like `.get()` or `.post()`
1229
- resolve their promises (before code inside `then` or `catch`, or after `await`)
1230
-
1231
- ```js
1232
- const instance = axios.create();
1233
-
1234
- // Add a request interceptor
1235
- instance.interceptors.request.use(
1236
- function (config) {
1237
- // Do something before the request is sent
1238
- return config;
1239
- },
1240
- function (error) {
1241
- // Do something with the request error
1242
- return Promise.reject(error);
1243
- }
1244
- );
1245
-
1246
- // Add a response interceptor
1247
- instance.interceptors.response.use(
1248
- function (response) {
1249
- // Any status code that lies within the range of 2xx causes this function to trigger
1250
- // Do something with response data
1251
- return response;
1252
- },
1253
- function (error) {
1254
- // Any status codes that fall outside the range of 2xx cause this function to trigger
1255
- // Do something with response error
1256
- return Promise.reject(error);
1257
- }
1258
- );
1259
- ```
1260
-
1261
- If you need to remove an interceptor later you can.
1262
-
1263
- ```js
1264
- const instance = axios.create();
1265
- const myInterceptor = instance.interceptors.request.use(function () {
1266
- /*...*/
1267
- });
1268
- instance.interceptors.request.eject(myInterceptor);
1269
- ```
1270
-
1271
- You can also clear all interceptors for requests or responses.
1272
-
1273
- ```js
1274
- const instance = axios.create();
1275
- instance.interceptors.request.use(function () {
1276
- /*...*/
1277
- });
1278
- instance.interceptors.request.clear(); // Removes interceptors from requests
1279
- instance.interceptors.response.use(function () {
1280
- /*...*/
1281
- });
1282
- instance.interceptors.response.clear(); // Removes interceptors from responses
1283
- ```
1284
-
1285
- You can add interceptors to a custom instance of axios.
1286
-
1287
- ```js
1288
- const instance = axios.create();
1289
- instance.interceptors.request.use(function () {
1290
- /*...*/
1291
- });
1292
- ```
1293
-
1294
- When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay
1295
- in the execution of your axios request when the main thread is blocked (a promise is created under the hood for
1296
- the interceptor and your request gets put at the bottom of the call stack). If your request interceptors are synchronous you can add a flag
1297
- to the options object that will tell axios to run the code synchronously and avoid any delays in request execution.
1298
-
1299
- ```js
1300
- axios.interceptors.request.use(
1301
- function (config) {
1302
- config.headers.test = 'I am only a header!';
1303
- return config;
1304
- },
1305
- null,
1306
- { synchronous: true }
1307
- );
1308
- ```
1309
-
1310
- If you want to execute a particular interceptor based on a runtime check,
1311
- you can add a `runWhen` function to the options object. The request interceptor will not run **if and only if** the return
1312
- of `runWhen` is `false`. Axios calls the function with the config
1313
- object (don't forget that you can bind your own arguments to it as well.) This can be handy when you have an
1314
- asynchronous request interceptor that only needs to run at certain times.
1315
-
1316
- ```js
1317
- function onGetCall(config) {
1318
- return config.method === 'get';
1319
- }
1320
- axios.interceptors.request.use(
1321
- function (config) {
1322
- config.headers.test = 'special get headers';
1323
- return config;
1324
- },
1325
- null,
1326
- { runWhen: onGetCall }
1327
- );
1328
- ```
1329
-
1330
- > Note: The options parameter (with `synchronous` and `runWhen` properties) is only supported for request interceptors at the moment.
1331
-
1332
- ### Interceptor execution order
1333
-
1334
- Request and response interceptors use different execution orders.
1335
-
1336
- Request interceptors run in reverse order (LIFO: last in, first out). The last interceptor added runs first.
1337
-
1338
- Response interceptors run in the order they were added (FIFO: first in, first out). The first interceptor added runs first.
1339
-
1340
- Example:
1341
-
1342
- ```js
1343
- const instance = axios.create();
1344
-
1345
- const interceptor = (id) => (base) => {
1346
- console.log(id);
1347
- return base;
1348
- };
1349
-
1350
- instance.interceptors.request.use(interceptor('Request Interceptor 1'));
1351
- instance.interceptors.request.use(interceptor('Request Interceptor 2'));
1352
- instance.interceptors.request.use(interceptor('Request Interceptor 3'));
1353
- instance.interceptors.response.use(interceptor('Response Interceptor 1'));
1354
- instance.interceptors.response.use(interceptor('Response Interceptor 2'));
1355
- instance.interceptors.response.use(interceptor('Response Interceptor 3'));
1356
-
1357
- // Console output:
1358
- // Request Interceptor 3
1359
- // Request Interceptor 2
1360
- // Request Interceptor 1
1361
- // [HTTP request is made]
1362
- // Response Interceptor 1
1363
- // Response Interceptor 2
1364
- // Response Interceptor 3
1365
- ```
1366
-
1367
- ### Multiple interceptors
1368
-
1369
- When a response is fulfilled and multiple response interceptors are registered:
1370
-
1371
- - Each interceptor runs in registration order.
1372
- - Each interceptor receives the result from the previous interceptor.
1373
- - The chain returns the result from the last interceptor.
1374
- - If a fulfillment interceptor throws, Axios skips the next fulfillment interceptor and calls the next rejection interceptor.
1375
- - After the error is caught, later fulfillment interceptors run again, just like in a promise chain.
1376
-
1377
- Read [the interceptor tests](./test/specs/interceptors.spec.js) to see all this in code.
1378
-
1379
- ## Error types
1380
-
1381
- Axios error messages include details that can help you debug the request.
1382
-
1383
- Axios errors use this structure:
1384
- | Property | Definition |
1385
- | -------- | ---------- |
1386
- | message | A quick summary of the error message and the status it failed with. |
1387
- | name | This defines where the error originated from. For axios, it will always be an 'AxiosError'. |
1388
- | stack | Stack trace for the error. |
1389
- | config | An axios config object with specific instance configurations defined by the user from when the request was made |
1390
- | code | Axios error code. The table below lists internal Axios error codes. |
1391
- | status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings.
1392
-
1393
- These are the internal Axios error codes:
1394
-
1395
- | Code | Definition |
1396
- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1397
- | ERR_BAD_OPTION_VALUE | Invalid value provided in axios configuration. |
1398
- | ERR_BAD_OPTION | Invalid option provided in axios configuration. |
1399
- | ERR_NOT_SUPPORT | Feature or method not supported in the current axios environment. |
1400
- | ERR_DEPRECATED | Deprecated feature or method used in axios. |
1401
- | ERR_INVALID_URL | Invalid URL provided for axios request. |
1402
- | ECONNABORTED | Typically indicates that the request has been timed out (unless `transitional.clarifyTimeoutError` is set) or aborted by the browser or its plugin. |
1403
- | ERR_CANCELED | The user explicitly canceled the request with an AbortSignal or CancelToken. |
1404
- | ETIMEDOUT | Request timed out after exceeding the configured Axios timeout. Set `transitional.clarifyTimeoutError` to `true`; otherwise Axios throws a generic `ECONNABORTED` error. |
1405
- | ERR_NETWORK | Network-related issue. In the browser, this error can also be caused by a [CORS](https://developer.mozilla.org/ru/docs/Web/HTTP/Guides/CORS) or [Mixed Content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content) policy violation. The browser does not allow the JS code to clarify the real reason for the error caused by security issues, so please check the console. |
1406
- | ERR_FR_TOO_MANY_REDIRECTS | Request exceeded the configured maximum number of redirects. |
1407
- | ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format. Usually related to a response with `5xx` status code. |
1408
- | ERR_BAD_REQUEST | The request has an unexpected format or is missing required parameters. Usually related to a response with `4xx` status code. |
1409
-
1410
- ## Handling errors
1411
-
1412
- By default, Axios rejects responses with status codes outside the 2xx range.
1413
-
1414
- ```js
1415
- axios.get('/user/12345').catch(function (error) {
1416
- if (error.response) {
1417
- // The request was made and the server responded with a status code
1418
- // that falls out of the range of 2xx
1419
- console.log(error.response.data);
1420
- console.log(error.response.status);
1421
- console.log(error.response.headers);
1422
- } else if (error.request) {
1423
- // The request was made but no response was received
1424
- // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
1425
- // http.ClientRequest in node.js
1426
- console.log(error.request);
1427
- } else {
1428
- // Something happened in setting up the request that triggered an Error
1429
- console.log('Error', error.message);
1430
- }
1431
- console.log(error.config);
1432
- });
1433
- ```
1434
-
1435
- Use `validateStatus` to override the default condition (`status >= 200 && status < 300`) and choose which HTTP status codes should reject.
1436
-
1437
- ```js
1438
- axios.get('/user/12345', {
1439
- validateStatus: function (status) {
1440
- return status < 500; // Resolve only if the status code is less than 500
1441
- },
1442
- });
1443
- ```
1444
-
1445
- By default, explicit `validateStatus: undefined` keeps legacy behavior and resolves every response status because `transitional.validateStatusUndefinedResolves` defaults to `true`. Set it to `false` to make explicit `validateStatus: undefined` behave like the option was omitted, so Axios uses the configured/default validator and rejects non-2xx responses by default.
1446
-
1447
- `validateStatus: null` still accepts every response status. If you disable the transitional behavior and intentionally want all statuses to resolve, use `null` or `() => true`.
1448
-
1449
- ```js
1450
- axios.get('/user/12345', {
1451
- validateStatus: undefined,
1452
- transitional: {
1453
- validateStatusUndefinedResolves: false,
1454
- },
1455
- });
1456
- ```
1457
-
1458
- Use `toJSON` to get more information about the HTTP error.
1459
-
1460
- ```js
1461
- axios.get('/user/12345').catch(function (error) {
1462
- console.log(error.toJSON());
1463
- });
1464
- ```
1465
-
1466
- To avoid logging secrets from `error.config`, pass a `redact` array in the request config. Matching config keys are masked case-insensitively at any depth when `AxiosError#toJSON()` is called.
1467
-
1468
- ```js
1469
- axios
1470
- .get('/user/12345', {
1471
- headers: { Authorization: 'Bearer token' },
1472
- redact: ['authorization'],
1473
- })
1474
- .catch(function (error) {
1475
- console.log(error.toJSON().config.headers.Authorization); // [REDACTED ****]
1476
- });
1477
- ```
1478
-
1479
- ## Handling timeouts
1480
-
1481
- ```js
1482
- async function fetchWithTimeout() {
1483
- try {
1484
- const response = await axios.get('https://example.com/data', {
1485
- timeout: 5000, // 5 seconds
1486
- transitional: {
1487
- // set to true if you prefer ETIMEDOUT over ECONNABORTED
1488
- clarifyTimeoutError: false,
1489
- },
1490
- });
1491
-
1492
- console.log('Response:', response.data);
1493
- } catch (error) {
1494
- if (axios.isAxiosError(error)) {
1495
- if (error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT') {
1496
- console.error('Request timed out. Please try again.');
1497
- return;
1498
- }
1499
-
1500
- console.error('Axios error:', error.message);
1501
- return;
1502
- }
1503
-
1504
- console.error('Unexpected error:', error);
1505
- }
1506
- }
1507
- ```
1508
-
1509
- ## Cancellation
1510
-
1511
- ### AbortController
1512
-
1513
- Since `v0.22.0`, Axios supports AbortController:
1514
-
1515
- ```js
1516
- const controller = new AbortController();
1517
-
1518
- axios
1519
- .get('/foo/bar', {
1520
- signal: controller.signal,
1521
- })
1522
- .then(function (response) {
1523
- //...
1524
- });
1525
- // cancel the request
1526
- controller.abort();
1527
- ```
1528
-
1529
- ### CancelToken (deprecated)
1530
-
1531
- You can also cancel a request using a _CancelToken_.
1532
-
1533
- > The axios cancel token API is based on the withdrawn [cancellable promises proposal](https://github.com/tc39/proposal-cancelable-promises).
1534
-
1535
- > This API is deprecated since v0.22.0 and should not be used in new projects.
1536
-
1537
- Create a cancel token with the `CancelToken.source` factory:
1538
-
1539
- ```js
1540
- const CancelToken = axios.CancelToken;
1541
- const source = CancelToken.source();
1542
-
1543
- axios
1544
- .get('/user/12345', {
1545
- cancelToken: source.token,
1546
- })
1547
- .catch(function (thrown) {
1548
- if (axios.isCancel(thrown)) {
1549
- console.log('Request canceled', thrown.message);
1550
- } else {
1551
- // handle error
1552
- }
1553
- });
1554
-
1555
- axios.post(
1556
- '/user/12345',
1557
- {
1558
- name: 'new name',
1559
- },
1560
- {
1561
- cancelToken: source.token,
1562
- }
1563
- );
1564
-
1565
- // cancel the request (the message parameter is optional)
1566
- source.cancel('Operation canceled by the user.');
1567
- ```
1568
-
1569
- You can also pass an executor function to the `CancelToken` constructor:
1570
-
1571
- ```js
1572
- const CancelToken = axios.CancelToken;
1573
- let cancel;
1574
-
1575
- axios.get('/user/12345', {
1576
- cancelToken: new CancelToken(function executor(c) {
1577
- // An executor function receives a cancel function as a parameter
1578
- cancel = c;
1579
- }),
1580
- });
1581
-
1582
- // cancel the request
1583
- cancel();
1584
- ```
1585
-
1586
- `CancelToken` also exposes low-level helpers for legacy integrations:
1587
-
1588
- ```js
1589
- const source = axios.CancelToken.source();
1590
-
1591
- const listener = (cancel) => {
1592
- console.log(cancel.message);
1593
- };
1594
-
1595
- source.token.subscribe(listener);
1596
-
1597
- const signal = source.token.toAbortSignal();
1598
- // Pass `signal` to APIs that accept AbortSignal.
1599
-
1600
- source.cancel('Operation canceled by the user.');
1601
- source.token.unsubscribe(listener);
1602
- ```
1603
-
1604
- Canceled requests reject with `axios.CanceledError`. The legacy `axios.Cancel` export is an alias of `axios.CanceledError`, and cancellation errors include `__CANCEL__` for `axios.isCancel` compatibility.
1605
-
1606
- > Note: You can cancel several requests with the same cancel token or abort controller.
1607
- > If a cancellation token is already cancelled when an Axios request starts, Axios cancels the request immediately without making a real request.
1608
-
1609
- > During the transition period, you can use both cancellation APIs, even for the same request:
1610
-
1611
- ```js
1612
- const controller = new AbortController();
1613
- const source = axios.CancelToken.source();
1614
-
1615
- axios.get('/user/12345', {
1616
- cancelToken: source.token,
1617
- signal: controller.signal,
1618
- });
1619
-
1620
- controller.abort();
1621
- source.cancel('Operation canceled by the user.');
1622
- ```
1623
-
1624
- ## Using `application/x-www-form-urlencoded` format
1625
-
1626
- ### URLSearchParams
1627
-
1628
- By default, axios serializes JavaScript objects to `JSON`. To send data as [`application/x-www-form-urlencoded`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST), use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API. It works in most browsers and in [Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) v10 and later.
1629
-
1630
- ```js
1631
- const params = new URLSearchParams({ foo: 'bar' });
1632
- params.append('extraparam', 'value');
1633
- axios.post('/foo', params);
1634
- ```
1635
-
1636
- ### Query string (older browsers)
1637
-
1638
- For very old browsers, use a [polyfill](https://github.com/WebReflection/url-search-params) and make sure it patches the global environment.
1639
-
1640
- Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library:
1641
-
1642
- ```js
1643
- const qs = require('qs');
1644
- axios.post('/foo', qs.stringify({ bar: 123 }));
1645
- ```
1646
-
1647
- With ES modules:
1648
-
1649
- ```js
1650
- import qs from 'qs';
1651
- const data = { bar: 123 };
1652
- const options = {
1653
- method: 'POST',
1654
- headers: { 'content-type': 'application/x-www-form-urlencoded' },
1655
- data: qs.stringify(data),
1656
- url,
1657
- };
1658
- axios(options);
1659
- ```
1660
-
1661
- ### Older Node.js versions
1662
-
1663
- For older Node.js engines, use the [`querystring`](https://nodejs.org/api/querystring.html) module:
1664
-
1665
- ```js
1666
- const querystring = require('querystring');
1667
- axios.post('https://something.com/', querystring.stringify({ foo: 'bar' }));
1668
- ```
1669
-
1670
- You can also use the [`qs`](https://github.com/ljharb/qs) library.
1671
-
1672
- > Note: The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has [known issues](https://github.com/nodejs/node-v0.x-archive/issues/1665) with that use case.
1673
-
1674
- ### Automatic serialization to URLSearchParams
1675
-
1676
- Axios automatically serializes the data object to urlencoded format if the content-type header is set to "application/x-www-form-urlencoded".
1677
-
1678
- ```js
1679
- const data = {
1680
- x: 1,
1681
- arr: [1, 2, 3],
1682
- arr2: [1, [2], 3],
1683
- users: [
1684
- { name: 'Peter', surname: 'Griffin' },
1685
- { name: 'Thomas', surname: 'Anderson' },
1686
- ],
1687
- };
1688
-
1689
- await axios.postForm('https://postman-echo.com/post', data, {
1690
- headers: { 'content-type': 'application/x-www-form-urlencoded' },
1691
- });
1692
- ```
1693
-
1694
- The server receives these fields:
1695
-
1696
- ```js
1697
- {
1698
- x: '1',
1699
- 'arr[]': [ '1', '2', '3' ],
1700
- 'arr2[0]': '1',
1701
- 'arr2[1][0]': '2',
1702
- 'arr2[2]': '3',
1703
- 'arr3[]': [ '1', '2', '3' ],
1704
- 'users[0][name]': 'Peter',
1705
- 'users[0][surname]': 'griffin',
1706
- 'users[1][name]': 'Thomas',
1707
- 'users[1][surname]': 'Anderson'
1708
- }
1709
- ```
1710
-
1711
- If your backend body parser, such as `body-parser` for `express.js`, supports nested object decoding, the server receives the same object structure:
1712
-
1713
- ```js
1714
- const app = express();
1715
-
1716
- app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
1717
-
1718
- app.post('/', function (req, res, next) {
1719
- // echo body as JSON
1720
- res.send(JSON.stringify(req.body));
1721
- });
1722
-
1723
- server = app.listen(3000);
1724
- ```
1725
-
1726
- ## Using `multipart/form-data` format
1727
-
1728
- ### FormData
1729
-
1730
- To send data as `multipart/form-data`, pass a FormData instance as the payload.
1731
- You do not need to set the `Content-Type` header. Axios detects it from the payload type.
1732
- For browser, web worker, and React Native `FormData`, leave `Content-Type` unset so the runtime can add the multipart boundary.
1733
-
1734
- ```js
1735
- const formData = new FormData();
1736
- formData.append('foo', 'bar');
1737
-
1738
- axios.post('https://httpbin.org/post', formData);
1739
- ```
1740
-
1741
- In node.js, use the [`form-data`](https://github.com/form-data/form-data) library:
1742
-
1743
- ```js
1744
- const FormData = require('form-data');
1745
-
1746
- const form = new FormData();
1747
- form.append('my_field', 'my value');
1748
- form.append('my_buffer', Buffer.alloc(10));
1749
- form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
1750
-
1751
- axios.post('https://example.com', form);
1752
- ```
1753
-
1754
- In node.js, when a `FormData` object provides `getHeaders()`, axios copies all returned headers by default for v1 compatibility. If the `FormData` object is custom or not fully trusted, set `formDataHeaderPolicy: 'content-only'` to copy only `Content-Type` and `Content-Length`, and set any other request headers explicitly with the request `headers` config.
1755
-
1756
- ### Automatic serialization to FormData
1757
-
1758
- Since `v0.27.0`, Axios can serialize an object to FormData if the request `Content-Type`
1759
- header is set to `multipart/form-data`.
1760
-
1761
- This request submits data as FormData in browsers and Node.js:
1762
-
1763
- ```js
1764
- import axios from 'axios';
1765
-
1766
- axios
1767
- .post(
1768
- 'https://httpbin.org/post',
1769
- { x: 1 },
1770
- {
1771
- headers: {
1772
- 'Content-Type': 'multipart/form-data',
1773
- },
1774
- }
1775
- )
1776
- .then(({ data }) => console.log(data));
1777
- ```
1778
-
1779
- The Node.js build uses the [`form-data`](https://github.com/form-data/form-data) polyfill by default.
1780
-
1781
- You can override the FormData class with the `env.FormData` config option, but most applications do not need this:
1782
-
1783
- ```js
1784
- const axios = require('axios');
1785
- var FormData = require('form-data');
1786
-
1787
- axios
1788
- .post(
1789
- 'https://httpbin.org/post',
1790
- { x: 1, buf: Buffer.alloc(10) },
1791
- {
1792
- headers: {
1793
- 'Content-Type': 'multipart/form-data',
1794
- },
1795
- }
1796
- )
1797
- .then(({ data }) => console.log(data));
1798
- ```
1799
-
1800
- The Axios FormData serializer supports these special endings:
1801
-
1802
- - `{}` - serialize the value with JSON.stringify
1803
- - `[]` - unwrap the array-like object as separate fields with the same key
1804
-
1805
- > Note: Arrays and FileList objects are unwrapped by default.
1806
-
1807
- FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases:
1808
-
1809
- - `visitor: Function` - user-defined visitor function that Axios calls recursively to serialize the data object
1810
- to a `FormData` object by following custom rules.
1811
-
1812
- - `dots: boolean = false` - use dot notation instead of brackets to serialize arrays and objects;
1813
-
1814
- - `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key.
1815
- A backend body parser can use this meta-information to parse the value as JSON.
1816
-
1817
- - `indexes: null|false|true = false` - controls how Axios adds indexes to unwrapped keys of `flat` array-like objects.
1818
- - `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`)
1819
- - `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`)
1820
- - `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`)
1821
- - `maxDepth: number = 100` - maximum object nesting depth the serializer will recurse into. If the
1822
- input object exceeds this depth, an `AxiosError` with `code: 'ERR_FORM_DATA_DEPTH_EXCEEDED'` is
1823
- thrown instead of overflowing the call stack. This protects server applications from DoS
1824
- attacks via deeply nested payloads. Set to `Infinity` to disable the limit and restore pre-fix behaviour.
1825
- - `Blob: typeof Blob` - Blob constructor used when converting ArrayBuffer-like values for spec-compliant
1826
- `FormData`. Override it only for runtimes that provide a compatible `Blob` constructor under a
1827
- different binding.
1828
-
1829
- ```js
1830
- // Raise the limit for a schema that genuinely nests deeper than 100 levels:
1831
- axios.postForm('/api', data, { formSerializer: { maxDepth: 200 } });
1832
-
1833
- // Same protection applies to params serialization:
1834
- axios.get('/api', { params: data, paramsSerializer: { maxDepth: 200 } });
1835
- ```
1836
-
1837
- Given this object:
1838
-
1839
- ```js
1840
- const obj = {
1841
- x: 1,
1842
- arr: [1, 2, 3],
1843
- arr2: [1, [2], 3],
1844
- users: [
1845
- { name: 'Peter', surname: 'Griffin' },
1846
- { name: 'Thomas', surname: 'Anderson' },
1847
- ],
1848
- 'obj2{}': [{ x: 1 }],
1849
- };
1850
- ```
1851
-
1852
- The Axios serializer appends these fields:
1853
-
1854
- ```js
1855
- const formData = new FormData();
1856
- formData.append('x', '1');
1857
- formData.append('arr[]', '1');
1858
- formData.append('arr[]', '2');
1859
- formData.append('arr[]', '3');
1860
- formData.append('arr2[0]', '1');
1861
- formData.append('arr2[1][0]', '2');
1862
- formData.append('arr2[2]', '3');
1863
- formData.append('users[0][name]', 'Peter');
1864
- formData.append('users[0][surname]', 'Griffin');
1865
- formData.append('users[1][name]', 'Thomas');
1866
- formData.append('users[1][surname]', 'Anderson');
1867
- formData.append('obj2{}', '[{"x":1}]');
1868
- ```
1869
-
1870
- Axios supports `postForm`, `putForm`, and `patchForm` as shortcuts for the matching HTTP methods with the `Content-Type` header preset to `multipart/form-data`.
1871
-
1872
- ## Posting files
1873
-
1874
- Submit a single file:
1875
-
1876
- ```js
1877
- await axios.postForm('https://httpbin.org/post', {
1878
- myVar: 'foo',
1879
- file: document.querySelector('#fileInput').files[0],
1880
- });
1881
- ```
1882
-
1883
- or multiple files as `multipart/form-data`:
1884
-
1885
- ```js
1886
- await axios.postForm('https://httpbin.org/post', {
1887
- 'files[]': document.querySelector('#fileInput').files,
1888
- });
1889
- ```
1890
-
1891
- `FileList` object can be passed directly:
1892
-
1893
- ```js
1894
- await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files);
1895
- ```
1896
-
1897
- Axios sends all files with the same field name: `files[]`.
1898
-
1899
- ## HTML form posting (browser)
1900
-
1901
- Pass an HTML Form element as a payload to submit it as `multipart/form-data` content.
1902
-
1903
- ```js
1904
- await axios.postForm('https://httpbin.org/post', document.querySelector('#htmlForm'));
1905
- ```
1906
-
1907
- `FormData` and `HTMLForm` objects can also be posted as `JSON` by explicitly setting the `Content-Type` header to `application/json`:
1908
-
1909
- ```js
1910
- await axios.post('https://httpbin.org/post', document.querySelector('#htmlForm'), {
1911
- headers: {
1912
- 'Content-Type': 'application/json',
1913
- },
1914
- });
1915
- ```
1916
-
1917
- For example, the Form
1918
-
1919
- ```html
1920
- <form id="form">
1921
- <input type="text" name="foo" value="1" />
1922
- <input type="text" name="deep.prop" value="2" />
1923
- <input type="text" name="deep prop spaced" value="3" />
1924
- <input type="text" name="baz" value="4" />
1925
- <input type="text" name="baz" value="5" />
1926
-
1927
- <select name="user.age">
1928
- <option value="value1">Value 1</option>
1929
- <option value="value2" selected>Value 2</option>
1930
- <option value="value3">Value 3</option>
1931
- </select>
1932
-
1933
- <input type="submit" value="Save" />
1934
- </form>
1935
- ```
1936
-
1937
- submits this JSON object:
1938
-
1939
- ```js
1940
- {
1941
- "foo": "1",
1942
- "deep": {
1943
- "prop": {
1944
- "spaced": "3"
1945
- }
1946
- },
1947
- "baz": [
1948
- "4",
1949
- "5"
1950
- ],
1951
- "user": {
1952
- "age": "value2"
1953
- }
1954
- }
1955
- ```
1956
-
1957
- Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported.
1958
-
1959
- ## Progress capturing
1960
-
1961
- Axios can capture request upload and download progress in browsers and Node.js.
1962
- Progress events are limited to `3` times per second.
1963
-
1964
- ```js
1965
- await axios.post(url, data, {
1966
- onUploadProgress: function (axiosProgressEvent) {
1967
- /*{
1968
- loaded: number;
1969
- total?: number;
1970
- progress?: number; // in range [0..1]
1971
- bytes: number; // how many bytes have been transferred since the last trigger (delta)
1972
- estimated?: number; // estimated time in seconds
1973
- rate?: number; // upload speed in bytes
1974
- upload: true; // upload sign
1975
- }*/
1976
- },
1977
-
1978
- onDownloadProgress: function (axiosProgressEvent) {
1979
- /*{
1980
- loaded: number;
1981
- total?: number;
1982
- progress?: number;
1983
- bytes: number;
1984
- estimated?: number;
1985
- rate?: number; // download speed in bytes
1986
- download: true; // download sign
1987
- }*/
1988
- },
1989
- });
1990
- ```
1991
-
1992
- You can also track stream upload/download progress in node.js:
1993
-
1994
- ```js
1995
- const { data } = await axios.post(SERVER_URL, readableStream, {
1996
- onUploadProgress: ({ progress }) => {
1997
- console.log((progress * 100).toFixed(2));
1998
- },
1999
-
2000
- headers: {
2001
- 'Content-Length': contentLength,
2002
- },
2003
-
2004
- maxRedirects: 0, // avoid buffering the entire stream
2005
- });
2006
- ```
2007
-
2008
- > Note:
2009
- > Capturing FormData upload progress is not currently supported in node.js environments.
2010
-
2011
- > Warning:
2012
- > Set `maxRedirects: 0` when uploading streams in node.js.
2013
- > The follow-redirects package buffers the entire stream in RAM and does not follow the "backpressure" algorithm.
2014
-
2015
- ## Rate limiting
2016
-
2017
- Download and upload rate limits can only be set for the http adapter (node.js):
2018
-
2019
- ```js
2020
- const { data } = await axios.post(LOCAL_SERVER_URL, myBuffer, {
2021
- onUploadProgress: ({ progress, rate }) => {
2022
- console.log(`Upload [${(progress * 100).toFixed(2)}%]: ${(rate / 1024).toFixed(2)}KB/s`);
2023
- },
2024
-
2025
- maxRate: [100 * 1024], // 100KB/s limit
2026
- });
2027
- ```
2028
-
2029
- ## AxiosHeaders
2030
-
2031
- Axios includes an `AxiosHeaders` class for working with headers through a Map-like API.
2032
- HTTP header names are case-insensitive, but Axios keeps the original header case for style and for servers that incorrectly depend on case.
2033
- Directly manipulating the headers object still works, but it is deprecated.
2034
-
2035
- ### Working with headers
2036
-
2037
- An `AxiosHeaders` instance can contain several internal value types that control setting and merging.
2038
- Axios gets the final headers object with string values by calling `toJSON`.
2039
-
2040
- > Note: By JSON here we mean an object consisting only of string values intended to be sent over the network.
2041
-
2042
- The header value can be one of the following types:
2043
-
2044
- - `string` - normal string value sent to the server
2045
- - `null` - skip header when rendering to JSON
2046
- - `false` - skip header when rendering to JSON. Also indicates that the `set` method must be called with `rewrite` set to `true`
2047
- to overwrite this value (Axios uses this internally to allow users to opt out of installing certain headers like `User-Agent` or `Content-Type`)
2048
- - `undefined` - value is not set
2049
-
2050
- > Note: The header value is considered set if it is not equal to undefined.
2051
-
2052
- The headers object is always initialized inside interceptors and transformers:
2053
-
2054
- ```ts
2055
- axios.interceptors.request.use((request: InternalAxiosRequestConfig) => {
2056
- request.headers.set('My-header', 'value');
2057
-
2058
- request.headers.set({
2059
- 'My-set-header1': 'my-set-value1',
2060
- 'My-set-header2': 'my-set-value2',
2061
- });
2062
-
2063
- request.headers.set('User-Agent', false); // prevent Axios from setting this header later
2064
-
2065
- request.headers.setContentType('text/plain');
2066
-
2067
- request.headers['My-set-header2'] = 'newValue'; // direct access is deprecated
2068
-
2069
- return request;
2070
- });
2071
- ```
2072
-
2073
- You can iterate over an `AxiosHeaders` instance using a `for...of` statement:
2074
-
2075
- ```js
2076
- const headers = new AxiosHeaders({
2077
- foo: '1',
2078
- bar: '2',
2079
- baz: '3',
2080
- });
2081
-
2082
- for (const [header, value] of headers) {
2083
- console.log(header, value);
2084
- }
2085
-
2086
- // foo 1
2087
- // bar 2
2088
- // baz 3
2089
- ```
2090
-
2091
- ### Preserving a specific header case
2092
-
2093
- Header names are case-insensitive, but `AxiosHeaders` keeps the case of the first matching key it sees.
2094
- If you need a specific case for non-standard case-sensitive servers, define a case preset with `undefined` and then set the value later:
2095
-
2096
- ```js
2097
- const api = axios.create();
2098
-
2099
- api.defaults.headers.common = {
2100
- 'content-type': undefined,
2101
- accept: undefined,
2102
- };
2103
-
2104
- await api.put(url, data, {
2105
- headers: {
2106
- 'Content-Type': 'application/octet-stream',
2107
- Accept: 'application/json',
2108
- },
2109
- });
2110
- ```
2111
-
2112
- You can also compose the same behavior with `AxiosHeaders.concat`:
2113
-
2114
- ```js
2115
- const headers = axios.AxiosHeaders.concat(
2116
- { 'content-type': undefined },
2117
- { 'Content-Type': 'application/octet-stream' }
2118
- );
2119
-
2120
- await axios.put(url, data, { headers });
2121
- ```
2122
-
2123
- ### new AxiosHeaders(headers?)
2124
-
2125
- Constructs a new `AxiosHeaders` instance.
2126
-
2127
- ```
2128
- constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
2129
- ```
2130
-
2131
- If the headers object is a string, Axios parses it as raw HTTP headers.
2132
-
2133
- ```js
2134
- const headers = new AxiosHeaders(`
2135
- Host: www.bing.com
2136
- User-Agent: curl/7.54.0
2137
- Accept: */*`);
2138
-
2139
- console.log(headers);
2140
-
2141
- // Object [AxiosHeaders] {
2142
- // host: 'www.bing.com',
2143
- // 'user-agent': 'curl/7.54.0',
2144
- // accept: '*/*'
2145
- // }
2146
- ```
2147
-
2148
- ### AxiosHeaders#set
2149
-
2150
- ```ts
2151
- set(headerName, value: Axios, rewrite?: boolean);
2152
- set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean);
2153
- set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean);
2154
- set(headers?: Iterable<[string, AxiosHeaderValue]>, rewrite?: boolean);
2155
- ```
2156
-
2157
- The `rewrite` argument controls the overwriting behavior:
2158
-
2159
- - `false` - do not overwrite if the header's value is set (is not `undefined`)
2160
- - `undefined` (default) - overwrite the header unless its value is set to `false`
2161
- - `true` - rewrite anyway
2162
-
2163
- The option can also accept a user-defined function that determines whether to overwrite the value.
2164
-
2165
- Empty or whitespace-only header names are ignored.
2166
-
2167
- Iterable key/value pairs, such as a `Map`, are accepted:
2168
-
2169
- ```js
2170
- const headers = new AxiosHeaders();
2171
-
2172
- headers.set(
2173
- new Map([
2174
- ['X-Trace-Id', 'abc123'],
2175
- ['Accept', 'application/json'],
2176
- ])
2177
- );
2178
- ```
2179
-
2180
- Returns `this`.
2181
-
2182
- ### AxiosHeaders#get(header)
2183
-
2184
- ```
2185
- get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
2186
- get(headerName: string, parser: RegExp): RegExpExecArray | null;
2187
- ```
2188
-
2189
- Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`,
2190
- matcher function or internal key-value parser.
2191
-
2192
- ```ts
2193
- const headers = new AxiosHeaders({
2194
- 'Content-Type': 'multipart/form-data; boundary=Asrf456BGe4h',
2195
- });
2196
-
2197
- console.log(headers.get('Content-Type'));
2198
- // multipart/form-data; boundary=Asrf456BGe4h
2199
-
2200
- console.log(headers.get('Content-Type', true)); // parse key-value pairs from a string separated with \s,;= delimiters:
2201
- // [Object: null prototype] {
2202
- // 'multipart/form-data': undefined,
2203
- // boundary: 'Asrf456BGe4h'
2204
- // }
2205
-
2206
- console.log(
2207
- headers.get('Content-Type', (value, name, headers) => {
2208
- return String(value).replace(/a/g, 'ZZZ');
2209
- })
2210
- );
2211
- // multipZZZrt/form-dZZZtZZZ; boundZZZry=Asrf456BGe4h
2212
-
2213
- console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]);
2214
- // boundary=Asrf456BGe4h
2215
- ```
2216
-
2217
- Returns the value of the header.
2218
-
2219
- ### AxiosHeaders#has(header, matcher?)
2220
-
2221
- ```
2222
- has(header: string, matcher?: AxiosHeaderMatcher): boolean;
2223
- ```
2224
-
2225
- Returns `true` if the header is set (has no `undefined` value).
2226
-
2227
- ### AxiosHeaders#delete(header, matcher?)
2228
-
2229
- ```
2230
- delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
2231
- ```
2232
-
2233
- Returns `true` if at least one header has been removed.
2234
-
2235
- ### AxiosHeaders#clear(matcher?)
2236
-
2237
- ```
2238
- clear(matcher?: AxiosHeaderMatcher): boolean;
2239
- ```
2240
-
2241
- Removes all headers.
2242
- Unlike the `delete` method matcher, this optional matcher matches the header name rather than the value.
2243
-
2244
- ```ts
2245
- const headers = new AxiosHeaders({
2246
- foo: '1',
2247
- 'x-foo': '2',
2248
- 'x-bar': '3',
2249
- });
2250
-
2251
- console.log(headers.clear(/^x-/)); // true
2252
-
2253
- console.log(headers.toJSON()); // [Object: null prototype] { foo: '1' }
2254
- ```
2255
-
2256
- Returns `true` if at least one header has been cleared.
2257
-
2258
- ### AxiosHeaders#normalize(format);
2259
-
2260
- If the headers object was changed directly, it can have duplicates with the same name but in different cases.
2261
- This method normalizes the headers object by combining duplicate keys into one.
2262
- Axios uses this method internally after calling each interceptor.
2263
- Set `format` to true for converting header names to lowercase and capitalizing the initial letters (`cOntEnt-type` => `Content-Type`)
2264
-
2265
- ```js
2266
- const headers = new AxiosHeaders({
2267
- foo: '1',
2268
- });
2269
-
2270
- headers.Foo = '2';
2271
- headers.FOO = '3';
2272
-
2273
- console.log(headers.toJSON()); // [Object: null prototype] { foo: '1', Foo: '2', FOO: '3' }
2274
- console.log(headers.normalize().toJSON()); // [Object: null prototype] { foo: '3' }
2275
- console.log(headers.normalize(true).toJSON()); // [Object: null prototype] { Foo: '3' }
2276
- ```
2277
-
2278
- Returns `this`.
2279
-
2280
- ### AxiosHeaders#concat(...targets)
2281
-
2282
- ```
2283
- concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
2284
- ```
2285
-
2286
- Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, Axios parses it as raw HTTP headers.
2287
-
2288
- Returns a new `AxiosHeaders` instance.
2289
-
2290
- ### AxiosHeaders#toJSON(asStrings?)
2291
-
2292
- ```
2293
- toJSON(asStrings: true): Record<string, string>;
2294
- toJSON(asStrings?: false): Record<string, string | string[]>;
2295
- ```
2296
-
2297
- Resolves all internal header values into a new null prototype object.
2298
- Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas.
2299
-
2300
- ### AxiosHeaders#toString()
2301
-
2302
- ```
2303
- toString(): string;
2304
- ```
2305
-
2306
- Returns the headers as a CRLF-free HTTP header block, one `name: value` pair per line.
2307
-
2308
- ### AxiosHeaders.from(thing?)
2309
-
2310
- ```
2311
- from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
2312
- ```
2313
-
2314
- Returns a new `AxiosHeaders` instance created from the raw headers passed in,
2315
- or returns the given headers object if it's already an `AxiosHeaders` instance.
2316
-
2317
- ### AxiosHeaders.concat(...targets)
2318
-
2319
- ```
2320
- concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
2321
- ```
2322
-
2323
- Returns a new `AxiosHeaders` instance created by merging the target objects.
2324
-
2325
- ### Shortcuts
2326
-
2327
- The following shortcuts are available:
2328
-
2329
- - `setContentType`, `getContentType`, `hasContentType`
2330
-
2331
- - `setContentLength`, `getContentLength`, `hasContentLength`
2332
-
2333
- - `setAccept`, `getAccept`, `hasAccept`
2334
-
2335
- - `setUserAgent`, `getUserAgent`, `hasUserAgent`
2336
-
2337
- - `setContentEncoding`, `getContentEncoding`, `hasContentEncoding`
2338
-
2339
- ## Fetch adapter
2340
-
2341
- Axios introduced the fetch adapter in `v1.7.0`. By default, Axios uses it when the `xhr` and `http` adapters are not available in the build or not supported by the environment.
2342
- To use it by default, select it explicitly:
2343
-
2344
- ```js
2345
- const { data } = axios.get(url, {
2346
- adapter: 'fetch', // by default ['xhr', 'http', 'fetch']
2347
- });
2348
- ```
2349
-
2350
- You can create a separate instance for this:
2351
-
2352
- ```js
2353
- const fetchAxios = axios.create({
2354
- adapter: 'fetch',
2355
- });
2356
-
2357
- const { data } = fetchAxios.get(url);
2358
- ```
2359
-
2360
- The adapter supports the same features as the `xhr` adapter, including upload and download progress capturing.
2361
- It also supports response types such as `stream` and `formdata` when the environment supports them.
2362
-
2363
- When `auth` is omitted, the fetch adapter can read HTTP Basic auth credentials from the request URL, for example `https://user:pass@example.com`. Percent-encoded URL credentials are decoded before the `Authorization` header is generated, and `auth` takes precedence over URL-embedded credentials.
2364
-
2365
- ### Custom fetch
2366
-
2367
- Since `v1.12.0`, you can configure the fetch adapter to use a custom fetch API instead of environment globals.
2368
- Pass a custom `fetch` function, `Request`, and `Response` constructors through `env` config.
2369
- This helps in custom environments and app frameworks.
2370
-
2371
- When using a custom fetch, you may also need to set custom `Request` and `Response` constructors. If you do not set them, Axios uses the global objects.
2372
- If your custom fetch API does not provide these objects and the globals are incompatible with it, pass `null` to disable them inside the fetch adapter.
2373
-
2374
- > Note: Setting `Request` and `Response` to `null` prevents the fetch adapter from capturing upload and download progress.
2375
-
2376
- Basic example:
2377
-
2378
- ```js
2379
- import customFetchFunction from 'customFetchModule';
2380
-
2381
- const instance = axios.create({
2382
- adapter: 'fetch',
2383
- onDownloadProgress(e) {
2384
- console.log('downloadProgress', e);
2385
- },
2386
- env: {
2387
- fetch: customFetchFunction,
2388
- Request: null, // undefined -> use the global constructor
2389
- Response: null,
2390
- },
2391
- });
2392
- ```
2393
-
2394
- #### Using with Tauri
2395
-
2396
- A minimal example of setting up Axios for use in a [Tauri](https://tauri.app/plugin/http-client/) app with a platform fetch function that ignores CORS policy for requests.
2397
-
2398
- ```js
2399
- import { fetch } from '@tauri-apps/plugin-http';
2400
- import axios from 'axios';
2401
-
2402
- const instance = axios.create({
2403
- adapter: 'fetch',
2404
- onDownloadProgress(e) {
2405
- console.log('downloadProgress', e);
2406
- },
2407
- env: {
2408
- fetch,
2409
- },
2410
- });
2411
-
2412
- const { data } = await instance.get('https://google.com');
2413
- ```
2414
-
2415
- #### Using with SvelteKit
2416
-
2417
- [SvelteKit](https://svelte.dev/docs/kit/web-standards#Fetch-APIs) uses a custom fetch function for server rendering in `load` functions. It also uses relative paths, which are incompatible with the standard URL API. Configure Axios to use SvelteKit's custom fetch API:
2418
-
2419
- ```js
2420
- export async function load({ fetch }) {
2421
- const { data: post } = await axios.get('https://jsonplaceholder.typicode.com/posts/1', {
2422
- adapter: 'fetch',
2423
- env: {
2424
- fetch,
2425
- Request: null,
2426
- Response: null,
2427
- },
2428
- });
2429
-
2430
- return { post };
2431
- }
2432
- ```
2433
-
2434
- #### HTTP/2 support
2435
-
2436
- Axios supports HTTP/2 through the Node.js `http` adapter, introduced in v1.13.0.
2437
-
2438
- Support depends on the runtime environment. Axios relies on Node.js APIs, so HTTP/2 works in supported Node.js versions but may not work in other environments such as Bun or Deno.
2439
-
2440
- Options like `httpVersion` and `http2Options` are adapter-specific and may not behave the same way in every environment.
2441
-
2442
- Note: HTTP/2 redirects are currently not supported by the HTTP/2 adapter.
2443
-
2444
- ```js
2445
- const form = new FormData();
2446
-
2447
- form.append('foo', '123');
2448
-
2449
- const { data, headers, status } = await axios.post('https://httpbin.org/post', form, {
2450
- onUploadProgress(e) {
2451
- console.log('upload progress', e);
2452
- },
2453
- onDownloadProgress(e) {
2454
- console.log('download progress', e);
2455
- },
2456
- responseType: 'arraybuffer',
2457
- });
2458
- ```
2459
-
2460
- ## Semver
2461
-
2462
- Axios follows [semver](https://semver.org/) since `v1.0.0`.
2463
-
2464
- ## Promises
2465
-
2466
- axios depends on a native ES6 Promise implementation to be [supported](https://caniuse.com/promises).
2467
- If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
2468
-
2469
- ## TypeScript
2470
-
2471
- axios includes [TypeScript](https://typescriptlang.org) definitions and a type guard for axios errors.
2472
-
2473
- ```typescript
2474
- let user: User = null;
2475
- try {
2476
- const { data } = await axios.get('/user?ID=12345');
2477
- user = data.userDetails;
2478
- } catch (error) {
2479
- if (axios.isAxiosError(error)) {
2480
- handleAxiosError(error);
2481
- } else {
2482
- handleUnexpectedError(error);
2483
- }
2484
- }
2485
- ```
2486
-
2487
- Use `axios.isCancel<T>()` to narrow cancellation errors to `CanceledError<T>`:
2488
-
2489
- ```typescript
2490
- const controller = new AbortController();
2491
-
2492
- try {
2493
- await axios.get<User>('/user?ID=12345', { signal: controller.signal });
2494
- } catch (error) {
2495
- if (axios.isCancel<User>(error)) {
2496
- handleCancellation(error);
2497
- }
2498
- }
2499
- ```
2500
-
2501
- Because axios publishes an ESM default export and a CJS `module.exports`, TypeScript has a few caveats.
2502
- The recommended setting is `"moduleResolution": "node16"`, which is implied by `"module": "node16"`. This requires TypeScript 4.7 or greater.
2503
- If you use ESM, your settings should be fine.
2504
- If you compile TypeScript to CJS and can't use `"moduleResolution": "node 16"`, enable `esModuleInterop`.
2505
- If you use TypeScript to type check CJS JavaScript code, your only option is to use `"moduleResolution": "node16"`.
2506
-
2507
- You can also create a custom instance with typed interceptors:
2508
-
2509
- ```typescript
2510
- import axios, { AxiosInstance, InternalAxiosRequestConfig } from 'axios';
2511
-
2512
- const apiClient: AxiosInstance = axios.create({
2513
- baseURL: 'https://api.example.com',
2514
- timeout: 10000,
2515
- });
2516
-
2517
- apiClient.interceptors.request.use((config: InternalAxiosRequestConfig) => {
2518
- // Add auth token
2519
- return config;
2520
- });
2521
- ```
2522
-
2523
- ## Online one-click setup
2524
-
2525
- You can use Gitpod, a free online IDE for open source projects, to contribute or run the examples online.
2526
-
2527
- [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/main/examples/server.js)
2528
-
2529
- ## Contributing
2530
-
2531
- ### Local setup
2532
-
2533
- As a supply-chain hardening measure, this repository ships a project-level `.npmrc` that sets `ignore-scripts=true`. This blocks npm lifecycle scripts (`preinstall`, `install`, `postinstall`, `prepare`) from any direct or transitive dependency when you run `npm install` or `npm ci` inside the repo. See [THREATMODEL.md](./THREATMODEL.md) (threat T-S2) for the rationale.
2534
-
2535
- One consequence: the repository's own `prepare` hook (which installs Husky's git hooks) will **not** run automatically. After your first install, enable the git hooks manually:
2536
-
2537
- ```bash
2538
- npm ci
2539
- npm rebuild husky && npx husky
2540
- ```
2541
-
2542
- Run those two commands once per fresh checkout. You do **not** need to re-run them after every subsequent `npm install`.
2543
-
2544
- Do not remove `ignore-scripts=true` from `.npmrc` to "fix" this. That reopens the lifecycle-script attack surface for every other package in the tree. All CI workflows already invoke npm with `--ignore-scripts`, so local behaviour matches CI.
2545
-
2546
- ## Resources
2547
-
2548
- - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
2549
- - [Ecosystem](https://github.com/axios/axios/blob/v1.x/ECOSYSTEM.md)
2550
- - [Contributing Guide](https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md)
2551
- - [Code of Conduct](https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md)
2552
-
2553
- ## Credits
2554
-
2555
- axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) in [AngularJS](https://angularjs.org/). It provides a standalone `$http`-like service for use outside AngularJS.
2556
-
2557
- ## License
2558
-
2559
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)