@wopee-io/wopee.wdio 4.0.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/adapter/fullPageScreenshotAdapter/default.d.ts +4 -0
- package/build/adapter/fullPageScreenshotAdapter/default.d.ts.map +1 -0
- package/build/adapter/fullPageScreenshotAdapter/default.js +13 -0
- package/build/adapter/fullPageScreenshotAdapter/default.js.map +1 -0
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.d.ts +1 -9
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.d.ts.map +1 -1
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.interface.d.ts +24 -0
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.interface.d.ts.map +1 -0
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.interface.js +2 -0
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.interface.js.map +1 -0
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.js +8 -18
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.js.map +1 -1
- package/build/adapter/fullPageScreenshotAdapter/swipe.d.ts +4 -0
- package/build/adapter/fullPageScreenshotAdapter/swipe.d.ts.map +1 -0
- package/build/adapter/fullPageScreenshotAdapter/swipe.js +19 -0
- package/build/adapter/fullPageScreenshotAdapter/swipe.js.map +1 -0
- package/build/core/domain/valueObjects/track.interface.d.ts +7 -3
- package/build/core/domain/valueObjects/track.interface.d.ts.map +1 -1
- package/build/core/domain/valueObjects/track.interface.js.map +1 -1
- package/build/{port/clientSideOperationPort → core/ports}/clientSideOperationPort.d.ts +1 -1
- package/build/core/ports/clientSideOperationPort.d.ts.map +1 -0
- package/build/core/ports/clientSideOperationPort.js.map +1 -0
- package/build/domain/model/config.interface.d.ts +2 -2
- package/build/domain/model/config.interface.d.ts.map +1 -1
- package/build/domain/model/config.interface.js.map +1 -1
- package/build/domain/model/instances.interface.d.ts +2 -2
- package/build/domain/model/instances.interface.d.ts.map +1 -1
- package/build/domain/model/instances.interface.js.map +1 -1
- package/build/domain/model/screenshotOutput.interface.d.ts +2 -2
- package/build/domain/model/screenshotOutput.interface.d.ts.map +1 -1
- package/build/domain/model/screenshotOutput.interface.js.map +1 -1
- package/build/domain/model/service.interface.d.ts +2 -2
- package/build/domain/model/service.interface.d.ts.map +1 -1
- package/build/domain/model/service.interface.js.map +1 -1
- package/build/domain/service/afterScreenshot.js.map +1 -1
- package/build/domain/service/wopeeService.d.ts +5 -5
- package/build/domain/service/wopeeService.d.ts.map +1 -1
- package/build/domain/service/wopeeService.js +17 -14
- package/build/domain/service/wopeeService.js.map +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/getDocumentScrollHeight.d.ts.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/getDocumentScrollHeight.js.map +1 -0
- package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopDom.d.ts +1 -1
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopDom.d.ts.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopDom.js.map +1 -0
- package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopWindow.d.ts +1 -1
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopWindow.d.ts.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopWindow.js.map +1 -0
- package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/getScreenDimensions.d.ts +1 -1
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/getScreenDimensions.d.ts.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/getScreenDimensions.js.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/screenDimensions.interfaces.d.ts.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/screenDimensions.interfaces.js.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/scrollElementIntoView.d.ts.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/scrollElementIntoView.js.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/scrollToPosition.d.ts.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/clientSideScripts/scrollToPosition.js.map +1 -0
- package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/desktopBrowserClientOperationAdapter.d.ts +4 -4
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/desktopBrowserClientOperationAdapter.d.ts.map +1 -0
- package/build/infrastructure/adapters/desktopBrowserClientOperationAdapter/desktopBrowserClientOperationAdapter.js.map +1 -0
- package/build/{adapter/driven → infrastructure/adapters}/wdioLoggerAdapter/wdioLoggerAdapter.d.ts +1 -1
- package/build/infrastructure/adapters/wdioLoggerAdapter/wdioLoggerAdapter.d.ts.map +1 -0
- package/build/{adapter → infrastructure/adapters}/wdioLoggerAdapter/wdioLoggerAdapter.js +1 -1
- package/build/infrastructure/adapters/wdioLoggerAdapter/wdioLoggerAdapter.js.map +1 -0
- package/build/utils/versionMetadata.js +2 -2
- package/docs/mobile_native.md +14 -1
- package/node_modules/@autonomous-testing/sdk/.commit.hbs +71 -0
- package/node_modules/@autonomous-testing/sdk/.github/workflows/ci_cd.yaml +12 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/createIntegrationScenarioPayload.interface.d.ts +14 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/createIntegrationScenarioPayload.interface.js +10 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/createIntegrationStepPayload.interface.d.ts +32 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/createIntegrationStepPayload.interface.js +16 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/createIntegrationSuitePayload.interface.d.ts +11 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/createIntegrationSuitePayload.interface.js +9 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/index.d.ts +14 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/index.js +16 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/integrationScenario.interface.d.ts +14 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/integrationScenario.interface.js +10 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/integrationStep.interface.d.ts +24 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/integrationStep.interface.js +20 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/integrationSuite.interface.d.ts +14 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/integrationSuite.interface.js +10 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/index.d.ts +1 -1
- package/node_modules/@autonomous-testing/sdk/build/core/domain/index.js +1 -1
- package/node_modules/@autonomous-testing/sdk/build/core/index.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/build/core/index.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/core/ports/api.d.ts +16 -0
- package/node_modules/@autonomous-testing/sdk/build/core/ports/api.js +7 -0
- package/node_modules/@autonomous-testing/sdk/build/core/ports/index.d.ts +3 -3
- package/node_modules/@autonomous-testing/sdk/build/core/ports/index.js +5 -5
- package/node_modules/@autonomous-testing/sdk/build/index.d.ts +4 -3
- package/node_modules/@autonomous-testing/sdk/build/index.js +5 -3
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.d.ts +19 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js +123 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/factories.d.ts +9 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/factories.js +144 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/index.d.ts +4 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/index.js +8 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.d.ts +235 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.js +82 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/mutations.d.ts +5 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/{apolloTrackAdapter/apolloTrackAdapterQueries.js → apolloAdapter/mutations.js} +19 -36
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/consoleLogger/consoleLogger.d.ts +1 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/consoleLogger/index.d.ts +1 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/consoleLogger/index.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/index.d.ts +3 -3
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/index.js +3 -3
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/noLogger/index.d.ts +1 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/noLogger/index.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/noLogger/noLogger.d.ts +1 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/index.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/index.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/apolloAdapterService.d.ts +4 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/apolloAdapterService.js +12 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/apolloService.interface.d.ts +7 -0
- package/node_modules/@autonomous-testing/sdk/build/{core/domain/valueObjects/index.js → infrastructure/services/apolloAdapterService/apolloService.interface.js} +1 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/index.d.ts +4 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/index.js +6 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/index.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/index.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/loggerService/loggerOptions.interface.d.ts +16 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/loggerService/loggerOptions.interface.js +12 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/loggerService/loggerService.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/loggerService/loggerService.js +17 -9
- package/node_modules/@autonomous-testing/sdk/build/shared/index.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/index.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/metadata/versionMetadata.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/index.d.ts +3 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/index.js +4 -3
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/mergeDicts/index.d.ts +3 -0
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/mergeDicts/index.js +7 -0
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/mergeDicts/mergeDicts.d.ts +17 -0
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/mergeDicts/mergeDicts.js +29 -0
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/zodHelper/index.d.ts +1 -1
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/zodHelper/index.js +2 -2
- package/node_modules/@autonomous-testing/sdk/package.json +5 -8
- package/node_modules/@autonomous-testing/sdk/release.config.mjs +55 -0
- package/node_modules/axios/CHANGELOG.md +941 -950
- package/node_modules/axios/LICENSE +16 -4
- package/node_modules/axios/README.md +124 -828
- package/node_modules/axios/SECURITY.md +3 -4
- package/node_modules/axios/UPGRADE_GUIDE.md +168 -0
- package/node_modules/axios/dist/axios.js +2343 -3920
- package/node_modules/axios/dist/axios.map +1 -0
- package/node_modules/axios/dist/axios.min.js +3 -2
- package/node_modules/axios/dist/axios.min.map +1 -0
- package/node_modules/axios/index.d.ts +83 -391
- package/node_modules/axios/index.js +1 -43
- package/node_modules/axios/lib/adapters/http.js +219 -480
- package/node_modules/axios/lib/adapters/xhr.js +93 -61
- package/node_modules/axios/lib/axios.js +22 -47
- package/node_modules/axios/lib/cancel/CancelToken.js +89 -91
- package/node_modules/axios/lib/cancel/CanceledError.js +6 -9
- package/node_modules/axios/lib/cancel/isCancel.js +2 -2
- package/node_modules/axios/lib/core/Axios.js +98 -166
- package/node_modules/axios/lib/core/AxiosError.js +9 -23
- package/node_modules/axios/lib/core/InterceptorManager.js +45 -62
- package/node_modules/axios/lib/core/buildFullPath.js +4 -5
- package/node_modules/axios/lib/core/dispatchRequest.js +32 -26
- package/node_modules/axios/lib/core/mergeConfig.js +53 -59
- package/node_modules/axios/lib/core/settle.js +4 -6
- package/node_modules/axios/lib/core/transformData.js +9 -15
- package/node_modules/axios/lib/defaults/env/FormData.js +2 -0
- package/node_modules/axios/lib/defaults/index.js +57 -72
- package/node_modules/axios/lib/defaults/transitional.js +1 -1
- package/node_modules/axios/lib/env/data.js +3 -1
- package/node_modules/axios/lib/helpers/bind.js +7 -3
- package/node_modules/axios/lib/helpers/buildURL.js +33 -26
- package/node_modules/axios/lib/helpers/combineURLs.js +3 -4
- package/node_modules/axios/lib/helpers/cookies.js +50 -39
- package/node_modules/axios/lib/helpers/deprecatedMethod.js +2 -4
- package/node_modules/axios/lib/helpers/isAbsoluteURL.js +2 -3
- package/node_modules/axios/lib/helpers/isAxiosError.js +3 -4
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +46 -45
- package/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/node_modules/axios/lib/helpers/null.js +1 -1
- package/node_modules/axios/lib/helpers/parseHeaders.js +22 -24
- package/node_modules/axios/lib/helpers/parseProtocol.js +3 -3
- package/node_modules/axios/lib/helpers/spread.js +2 -3
- package/node_modules/axios/lib/helpers/toFormData.js +36 -183
- package/node_modules/axios/lib/helpers/validator.js +15 -20
- package/node_modules/axios/lib/utils.js +187 -445
- package/node_modules/axios/package.json +33 -165
- package/node_modules/axios/tsconfig.json +14 -0
- package/node_modules/axios/tslint.json +6 -0
- package/node_modules/process/.eslintrc +21 -0
- package/node_modules/process/LICENSE +22 -0
- package/node_modules/process/README.md +26 -0
- package/node_modules/process/browser.js +184 -0
- package/node_modules/process/index.js +2 -0
- package/node_modules/process/package.json +27 -0
- package/node_modules/process/test.js +199 -0
- package/package.json +2 -2
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/getDocumentScrollHeight.d.ts.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/getDocumentScrollHeight.js.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopDom.d.ts.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopDom.js.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopWindow.d.ts.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopWindow.js.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/getScreenDimensions.d.ts.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/getScreenDimensions.js.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/screenDimensions.interfaces.d.ts.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/screenDimensions.interfaces.js.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/scrollElementIntoView.d.ts.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/scrollElementIntoView.js.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/scrollToPosition.d.ts.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/clientSideScripts/scrollToPosition.js.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/desktopBrowserClientOperationAdapter.d.ts.map +0 -1
- package/build/adapter/desktopBrowserClientOperationAdapter/desktopBrowserClientOperationAdapter.js.map +0 -1
- package/build/adapter/driven/wdioLoggerAdapter/wdioLoggerAdapter.d.ts.map +0 -1
- package/build/adapter/driven/wdioLoggerAdapter/wdioLoggerAdapter.js +0 -20
- package/build/adapter/driven/wdioLoggerAdapter/wdioLoggerAdapter.js.map +0 -1
- package/build/adapter/wdioLoggerAdapter/wdioLoggerAdapter.d.ts +0 -10
- package/build/adapter/wdioLoggerAdapter/wdioLoggerAdapter.d.ts.map +0 -1
- package/build/adapter/wdioLoggerAdapter/wdioLoggerAdapter.js.map +0 -1
- package/build/port/clientSideOperationPort/clientSideOperationPort.d.ts.map +0 -1
- package/build/port/clientSideOperationPort/clientSideOperationPort.js.map +0 -1
- package/node_modules/@autonomous-testing/sdk/build/core/domain/valueObjects/imageTrackingResult.interface.d.ts +0 -3
- package/node_modules/@autonomous-testing/sdk/build/core/domain/valueObjects/imageTrackingResult.interface.js +0 -3
- package/node_modules/@autonomous-testing/sdk/build/core/domain/valueObjects/index.d.ts +0 -4
- package/node_modules/@autonomous-testing/sdk/build/core/domain/valueObjects/trackPayload.interface.d.ts +0 -3
- package/node_modules/@autonomous-testing/sdk/build/core/domain/valueObjects/trackPayload.interface.js +0 -3
- package/node_modules/@autonomous-testing/sdk/build/core/ports/imageTracker.d.ts +0 -6
- package/node_modules/@autonomous-testing/sdk/build/core/ports/imageTracker.js +0 -7
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapter.d.ts +0 -39
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapter.default.d.ts +0 -16
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapter.default.js +0 -31
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapter.interface.d.ts +0 -93
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapter.interface.js +0 -14
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapter.js +0 -153
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapterQueries.d.ts +0 -5
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapterUtils.d.ts +0 -9
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/apolloTrackAdapterUtils.js +0 -26
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/index.d.ts +0 -7
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloTrackAdapter/index.js +0 -8
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloTrackAdapterService/apolloTrackAdapterService.d.ts +0 -4
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloTrackAdapterService/apolloTrackAdapterService.interface.d.ts +0 -51
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloTrackAdapterService/apolloTrackAdapterService.interface.js +0 -24
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloTrackAdapterService/apolloTrackAdapterService.js +0 -13
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloTrackAdapterService/index.d.ts +0 -4
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloTrackAdapterService/index.js +0 -6
- package/node_modules/axios/MIGRATION_GUIDE.md +0 -3
- package/node_modules/axios/dist/axios.js.map +0 -1
- package/node_modules/axios/dist/axios.min.js.map +0 -1
- package/node_modules/axios/dist/browser/axios.cjs +0 -3638
- package/node_modules/axios/dist/browser/axios.cjs.map +0 -1
- package/node_modules/axios/dist/esm/axios.js +0 -3661
- package/node_modules/axios/dist/esm/axios.js.map +0 -1
- package/node_modules/axios/dist/esm/axios.min.js +0 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +0 -1
- package/node_modules/axios/dist/node/axios.cjs +0 -4705
- package/node_modules/axios/dist/node/axios.cjs.map +0 -1
- package/node_modules/axios/index.d.cts +0 -545
- package/node_modules/axios/lib/adapters/adapters.js +0 -79
- package/node_modules/axios/lib/adapters/fetch.js +0 -227
- package/node_modules/axios/lib/core/AxiosHeaders.js +0 -302
- package/node_modules/axios/lib/env/classes/FormData.js +0 -2
- package/node_modules/axios/lib/helpers/AxiosTransformStream.js +0 -192
- package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -58
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -71
- package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +0 -28
- package/node_modules/axios/lib/helpers/callbackify.js +0 -16
- package/node_modules/axios/lib/helpers/composeSignals.js +0 -46
- package/node_modules/axios/lib/helpers/formDataToJSON.js +0 -95
- package/node_modules/axios/lib/helpers/formDataToStream.js +0 -111
- package/node_modules/axios/lib/helpers/fromDataURI.js +0 -53
- package/node_modules/axios/lib/helpers/progressEventReducer.js +0 -32
- package/node_modules/axios/lib/helpers/readBlob.js +0 -15
- package/node_modules/axios/lib/helpers/resolveConfig.js +0 -57
- package/node_modules/axios/lib/helpers/speedometer.js +0 -55
- package/node_modules/axios/lib/helpers/throttle.js +0 -35
- package/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -18
- package/node_modules/axios/lib/helpers/trackStream.js +0 -55
- package/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
- package/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
- package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -4
- package/node_modules/axios/lib/platform/browser/index.js +0 -13
- package/node_modules/axios/lib/platform/common/utils.js +0 -50
- package/node_modules/axios/lib/platform/index.js +0 -7
- package/node_modules/axios/lib/platform/node/classes/FormData.js +0 -3
- package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +0 -4
- package/node_modules/axios/lib/platform/node/index.js +0 -12
- package/node_modules/proxy-from-env/.eslintrc +0 -29
- package/node_modules/proxy-from-env/.travis.yml +0 -10
- package/node_modules/proxy-from-env/LICENSE +0 -20
- package/node_modules/proxy-from-env/README.md +0 -131
- package/node_modules/proxy-from-env/index.js +0 -108
- package/node_modules/proxy-from-env/package.json +0 -34
- package/node_modules/proxy-from-env/test.js +0 -483
- /package/build/{port/clientSideOperationPort → core/ports}/clientSideOperationPort.js +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/getDocumentScrollHeight.d.ts +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/getDocumentScrollHeight.js +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopDom.js +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/getElementPositionTopWindow.js +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/getScreenDimensions.js +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/screenDimensions.interfaces.d.ts +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/screenDimensions.interfaces.js +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/scrollElementIntoView.d.ts +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/scrollElementIntoView.js +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/scrollToPosition.d.ts +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/clientSideScripts/scrollToPosition.js +0 -0
- /package/build/{adapter → infrastructure/adapters}/desktopBrowserClientOperationAdapter/desktopBrowserClientOperationAdapter.js +0 -0
- /package/node_modules/{mime-db → mime-types/node_modules/mime-db}/HISTORY.md +0 -0
- /package/node_modules/{mime-db → mime-types/node_modules/mime-db}/LICENSE +0 -0
- /package/node_modules/{mime-db → mime-types/node_modules/mime-db}/README.md +0 -0
- /package/node_modules/{mime-db → mime-types/node_modules/mime-db}/db.json +0 -0
- /package/node_modules/{mime-db → mime-types/node_modules/mime-db}/index.js +0 -0
- /package/node_modules/{mime-db → mime-types/node_modules/mime-db}/package.json +0 -0
|
@@ -1,100 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
Platinum sponsors
|
|
3
|
-
<br>
|
|
4
|
-
</h3>
|
|
5
|
-
|
|
6
|
-
<div align="center">
|
|
7
|
-
<a href="https://runalloy.com?utm_source=github&utm_medium=referral&utm_campaign=121423_axios">
|
|
8
|
-
<picture>
|
|
9
|
-
<source width="400px" media="(prefers-color-scheme: dark)" srcset="https://github.com/axios/axios/assets/4814473/f6067247-7eba-4069-852a-ab1bb85b1780">
|
|
10
|
-
<source width="400px" media="(prefers-color-scheme: light)" srcset="https://github.com/axios/axios/assets/4814473/75c37f4d-36e6-44f5-a068-3edd77c00a10">
|
|
11
|
-
<img width="400px" src="https://github.com/axios/axios/assets/4814473/75c37f4d-36e6-44f5-a068-3edd77c00a10" />
|
|
12
|
-
</picture>
|
|
13
|
-
</a>
|
|
14
|
-
|
|
15
|
-
<p align="center">Alloy is the integration development platform that makes it simple and <br>fast for SaaS companies to launch critical user-facing integrations.</p>
|
|
16
|
-
<p align="center">
|
|
17
|
-
<a href="https://runalloy.com/signup?utm_source=github&utm_medium=referral&utm_campaign=11823_axios"><b>Sign up free</b></a> •
|
|
18
|
-
<a href="https://docs.runalloy.com/docs?utm_source=github&utm_medium=referral&utm_campaign=11823_axios"><b>Documentation</b></a>
|
|
19
|
-
</p>
|
|
20
|
-
<br><br>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<h3 align="center">
|
|
24
|
-
Gold sponsors
|
|
25
|
-
<br><br>
|
|
26
|
-
</h3>
|
|
27
|
-
|
|
28
|
-
<table border="0">
|
|
29
|
-
<td align="center">
|
|
30
|
-
<a href="https://stytch.com?utm_source=oss-sponsorship&utm_medium=paid_sponsorship&utm_content=logo&utm_campaign=axios-http">
|
|
31
|
-
<picture>
|
|
32
|
-
<source width="200px" media="(prefers-color-scheme: dark)" srcset="https://github.com/axios/axios/assets/4814473/538d715a-13c7-4668-ae7d-37a4548423f4">
|
|
33
|
-
<source width="200px" media="(prefers-color-scheme: light)" srcset="https://github.com/axios/axios/assets/4814473/b6a9a7bc-9fb1-4b9b-909f-1b4bee1fd142">
|
|
34
|
-
<img width="200px" src="https://github.com/axios/axios/assets/4814473/b6a9a7bc-9fb1-4b9b-909f-1b4bee1fd142" />
|
|
35
|
-
</picture>
|
|
36
|
-
</a>
|
|
37
|
-
<p align="center">API-first authentication, authorization, and fraud prevention</p>
|
|
38
|
-
<p align="center">
|
|
39
|
-
<a href="https://stytch.com?utm_source=oss-sponsorship&utm_medium=paid_sponsorship&utm_content=website-link&utm_campaign=axios-http"><b>Website</b></a> •
|
|
40
|
-
<a href="https://stytch.com/docs?utm_source=oss-sponsorship&utm_medium=paid_sponsorship&utm_content=docs-link&utm_campaign=axios-http"><b>Documentation</b></a> • <a href="https://github.com/stytchauth/stytch-node?utm_source=oss-sponsorship&utm_medium=paid_sponsorship&utm_content=node-sdk&utm_campaign=axios-http"><b>Node.js Backend SDK</b></a>
|
|
41
|
-
</p>
|
|
42
|
-
</td>
|
|
43
|
-
<td align="center">
|
|
44
|
-
<a href="https://stytch.com?utm_source=oss-sponsorship&utm_medium=paid_sponsorship&utm_content=logo&utm_campaign=axios-http">
|
|
45
|
-
<picture>
|
|
46
|
-
<source width="200px" media="(prefers-color-scheme: dark)" srcset="https://github.com/axios/axios/assets/4814473/79f572f3-9d57-488d-80cc-58d674bb98d8">
|
|
47
|
-
<source width="200px" media="(prefers-color-scheme: light)" srcset="https://github.com/axios/axios/assets/4814473/18b51893-c4b4-4557-b263-74c2b3de84ab">
|
|
48
|
-
<img width="200px" src="https://github.com/axios/axios/assets/4814473/18b51893-c4b4-4557-b263-74c2b3de84ab" />
|
|
49
|
-
</picture>
|
|
50
|
-
</a>
|
|
51
|
-
<p align="center">Drag-and-drop authentication, authorization, and identity management</p>
|
|
52
|
-
<p align="center">
|
|
53
|
-
<a href="https://www.descope.com/?utm_source=axios&utm_medium=referral&utm_campaign=axios-oss-sponsorship"><b>Website</b></a> •
|
|
54
|
-
<a href="https://docs.descope.com/?utm_source=axios&utm_medium=referral&utm_campaign=axios-oss-sponsorship"><b>Documentation</b></a> • <a href="https://www.descope.com/community?utm_source=axios&utm_medium=referral&utm_campaign=axios-oss-sponsorship"><b>Community</b></a>
|
|
55
|
-
</p>
|
|
56
|
-
</td>
|
|
57
|
-
</table>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
<br><br>
|
|
61
|
-
<div align="center">
|
|
62
|
-
<a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" /></a><br>
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
<p align="center">Promise based HTTP client for the browser and node.js</p>
|
|
66
|
-
|
|
67
|
-
<p align="center">
|
|
68
|
-
<a href="https://axios-http.com/"><b>Website</b></a> •
|
|
69
|
-
<a href="https://axios-http.com/docs/intro"><b>Documentation</b></a>
|
|
70
|
-
</p>
|
|
71
|
-
|
|
72
|
-
<div align="center">
|
|
1
|
+
# axios
|
|
73
2
|
|
|
74
3
|
[](https://www.npmjs.org/package/axios)
|
|
75
4
|
[](https://cdnjs.com/libraries/axios)
|
|
76
|
-
|
|
77
|
-
[
|
|
6
|
+
[](https://gitpod.io/#https://github.com/axios/axios)
|
|
78
7
|
[](https://coveralls.io/r/mzabriskie/axios)
|
|
79
|
-
[](https://npm-stat.com/charts.html?package=axios)
|
|
8
|
+
[](https://packagephobia.now.sh/result?p=axios)
|
|
9
|
+
[](http://npm-stat.com/charts.html?package=axios)
|
|
82
10
|
[](https://gitter.im/mzabriskie/axios)
|
|
83
11
|
[](https://www.codetriage.com/axios/axios)
|
|
84
12
|
[](https://snyk.io/test/npm/axios)
|
|
85
13
|
|
|
14
|
+
Promise based HTTP client for the browser and node.js
|
|
86
15
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
</div>
|
|
16
|
+
> New axios docs website: [click here](https://axios-http.com/)
|
|
90
17
|
|
|
91
18
|
## Table of Contents
|
|
92
19
|
|
|
93
20
|
- [Features](#features)
|
|
94
21
|
- [Browser Support](#browser-support)
|
|
95
22
|
- [Installing](#installing)
|
|
96
|
-
- [Package manager](#package-manager)
|
|
97
|
-
- [CDN](#cdn)
|
|
98
23
|
- [Example](#example)
|
|
99
24
|
- [Axios API](#axios-api)
|
|
100
25
|
- [Request method aliases](#request-method-aliases)
|
|
@@ -114,18 +39,12 @@
|
|
|
114
39
|
- [AbortController](#abortcontroller)
|
|
115
40
|
- [CancelToken 👎](#canceltoken-deprecated)
|
|
116
41
|
- [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format)
|
|
117
|
-
- [
|
|
118
|
-
- [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
- [Files Posting](#files-posting)
|
|
124
|
-
- [HTML Form Posting](#-html-form-posting-browser)
|
|
125
|
-
- [🆕 Progress capturing](#-progress-capturing)
|
|
126
|
-
- [🆕 Rate limiting](#-progress-capturing)
|
|
127
|
-
- [🆕 AxiosHeaders](#-axiosheaders)
|
|
128
|
-
- [🔥 Fetch adapter](#-fetch-adapter)
|
|
42
|
+
- [Browser](#browser)
|
|
43
|
+
- [Node.js](#nodejs)
|
|
44
|
+
- [Query string](#query-string)
|
|
45
|
+
- [Form data](#form-data)
|
|
46
|
+
- [Automatic serialization](#-automatic-serialization)
|
|
47
|
+
- [Manual FormData passing](#manual-formdata-passing)
|
|
129
48
|
- [Semver](#semver)
|
|
130
49
|
- [Promises](#promises)
|
|
131
50
|
- [TypeScript](#typescript)
|
|
@@ -136,18 +55,17 @@
|
|
|
136
55
|
## Features
|
|
137
56
|
|
|
138
57
|
- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser
|
|
139
|
-
- Make [http](
|
|
58
|
+
- Make [http](http://nodejs.org/api/http.html) requests from node.js
|
|
140
59
|
- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API
|
|
141
60
|
- Intercept request and response
|
|
142
61
|
- Transform request and response data
|
|
143
62
|
- Cancel requests
|
|
144
|
-
- Automatic transforms for
|
|
145
|
-
-
|
|
146
|
-
- Client side support for protecting against [XSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery)
|
|
63
|
+
- Automatic transforms for JSON data
|
|
64
|
+
- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)
|
|
147
65
|
|
|
148
66
|
## Browser Support
|
|
149
67
|
|
|
150
|
-
 |  |  |  |  |  |
|
|
151
69
|
--- | --- | --- | --- | --- | --- |
|
|
152
70
|
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
|
|
153
71
|
|
|
@@ -155,8 +73,6 @@ Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
|
|
|
155
73
|
|
|
156
74
|
## Installing
|
|
157
75
|
|
|
158
|
-
### Package manager
|
|
159
|
-
|
|
160
76
|
Using npm:
|
|
161
77
|
|
|
162
78
|
```bash
|
|
@@ -175,64 +91,33 @@ Using yarn:
|
|
|
175
91
|
$ yarn add axios
|
|
176
92
|
```
|
|
177
93
|
|
|
178
|
-
Using
|
|
94
|
+
Using jsDelivr CDN:
|
|
179
95
|
|
|
180
|
-
```
|
|
181
|
-
|
|
96
|
+
```html
|
|
97
|
+
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
182
98
|
```
|
|
183
99
|
|
|
184
|
-
|
|
100
|
+
Using unpkg CDN:
|
|
185
101
|
|
|
186
|
-
```
|
|
187
|
-
|
|
102
|
+
```html
|
|
103
|
+
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
|
188
104
|
```
|
|
189
105
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
```js
|
|
193
|
-
import axios from 'axios';
|
|
194
|
-
|
|
195
|
-
console.log(axios.isCancel('something'));
|
|
196
|
-
````
|
|
197
|
-
|
|
198
|
-
If you use `require` for importing, **only default export is available**:
|
|
199
|
-
|
|
200
|
-
```js
|
|
201
|
-
const axios = require('axios');
|
|
202
|
-
|
|
203
|
-
console.log(axios.isCancel('something'));
|
|
204
|
-
```
|
|
106
|
+
## Example
|
|
205
107
|
|
|
206
|
-
|
|
207
|
-
|
|
108
|
+
### note: CommonJS usage
|
|
109
|
+
In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach:
|
|
208
110
|
|
|
209
111
|
```js
|
|
210
|
-
const axios = require('axios
|
|
211
|
-
// const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017)
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### CDN
|
|
215
|
-
|
|
216
|
-
Using jsDelivr CDN (ES5 UMD browser module):
|
|
112
|
+
const axios = require('axios').default;
|
|
217
113
|
|
|
218
|
-
|
|
219
|
-
<script src="https://cdn.jsdelivr.net/npm/axios@1.6.7/dist/axios.min.js"></script>
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
Using unpkg CDN:
|
|
223
|
-
|
|
224
|
-
```html
|
|
225
|
-
<script src="https://unpkg.com/axios@1.6.7/dist/axios.min.js"></script>
|
|
114
|
+
// axios.<method> will now provide autocomplete and parameter typings
|
|
226
115
|
```
|
|
227
116
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
> **Note**: CommonJS usage
|
|
231
|
-
> In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach:
|
|
117
|
+
Performing a `GET` request
|
|
232
118
|
|
|
233
119
|
```js
|
|
234
|
-
|
|
235
|
-
//const axios = require('axios'); // legacy way
|
|
120
|
+
const axios = require('axios').default;
|
|
236
121
|
|
|
237
122
|
// Make a request for a user with a given ID
|
|
238
123
|
axios.get('/user?ID=12345')
|
|
@@ -244,7 +129,7 @@ axios.get('/user?ID=12345')
|
|
|
244
129
|
// handle error
|
|
245
130
|
console.log(error);
|
|
246
131
|
})
|
|
247
|
-
.
|
|
132
|
+
.then(function () {
|
|
248
133
|
// always executed
|
|
249
134
|
});
|
|
250
135
|
|
|
@@ -260,9 +145,9 @@ axios.get('/user', {
|
|
|
260
145
|
.catch(function (error) {
|
|
261
146
|
console.log(error);
|
|
262
147
|
})
|
|
263
|
-
.
|
|
148
|
+
.then(function () {
|
|
264
149
|
// always executed
|
|
265
|
-
});
|
|
150
|
+
});
|
|
266
151
|
|
|
267
152
|
// Want to use async/await? Add the `async` keyword to your outer function/method.
|
|
268
153
|
async function getUser() {
|
|
@@ -275,7 +160,7 @@ async function getUser() {
|
|
|
275
160
|
}
|
|
276
161
|
```
|
|
277
162
|
|
|
278
|
-
> **
|
|
163
|
+
> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet
|
|
279
164
|
> Explorer and older browsers, so use with caution.
|
|
280
165
|
|
|
281
166
|
Performing a `POST` request
|
|
@@ -333,7 +218,7 @@ axios({
|
|
|
333
218
|
// GET request for remote image in node.js
|
|
334
219
|
axios({
|
|
335
220
|
method: 'get',
|
|
336
|
-
url: '
|
|
221
|
+
url: 'http://bit.ly/2mTM3nY',
|
|
337
222
|
responseType: 'stream'
|
|
338
223
|
})
|
|
339
224
|
.then(function (response) {
|
|
@@ -444,18 +329,11 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
444
329
|
params: {
|
|
445
330
|
ID: 12345
|
|
446
331
|
},
|
|
447
|
-
|
|
448
|
-
// `paramsSerializer` is an optional config that allows you to customize serializing `params`.
|
|
449
|
-
paramsSerializer: {
|
|
450
332
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ),
|
|
456
|
-
|
|
457
|
-
//Configuration for formatting array indexes in the params.
|
|
458
|
-
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).
|
|
333
|
+
// `paramsSerializer` is an optional function in charge of serializing `params`
|
|
334
|
+
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
|
|
335
|
+
paramsSerializer: function (params) {
|
|
336
|
+
return Qs.stringify(params, {arrayFormat: 'brackets'})
|
|
459
337
|
},
|
|
460
338
|
|
|
461
339
|
// `data` is the data to be sent as the request body
|
|
@@ -463,11 +341,11 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
463
341
|
// When no `transformRequest` is set, must be of one of the following types:
|
|
464
342
|
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
|
|
465
343
|
// - Browser only: FormData, File, Blob
|
|
466
|
-
// - Node only: Stream, Buffer
|
|
344
|
+
// - Node only: Stream, Buffer
|
|
467
345
|
data: {
|
|
468
346
|
firstName: 'Fred'
|
|
469
347
|
},
|
|
470
|
-
|
|
348
|
+
|
|
471
349
|
// syntax alternative to send data into the body
|
|
472
350
|
// method post
|
|
473
351
|
// only the value is sent, not the key
|
|
@@ -482,13 +360,10 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
482
360
|
withCredentials: false, // default
|
|
483
361
|
|
|
484
362
|
// `adapter` allows custom handling of requests which makes testing easier.
|
|
485
|
-
// Return a promise and supply a valid response (see lib/adapters/README.md)
|
|
363
|
+
// Return a promise and supply a valid response (see lib/adapters/README.md).
|
|
486
364
|
adapter: function (config) {
|
|
487
365
|
/* ... */
|
|
488
366
|
},
|
|
489
|
-
// Also, you can set the name of the built-in adapter, or provide an array with their names
|
|
490
|
-
// to choose the first available in the environment
|
|
491
|
-
adapter: 'xhr' // 'fetch' | 'http' | ['xhr', 'http', 'fetch']
|
|
492
367
|
|
|
493
368
|
// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
|
|
494
369
|
// This will set an `Authorization` header, overwriting any existing
|
|
@@ -507,9 +382,6 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
507
382
|
|
|
508
383
|
// `responseEncoding` indicates encoding to use for decoding responses (Node.js only)
|
|
509
384
|
// Note: Ignored for `responseType` of 'stream' or client-side requests
|
|
510
|
-
// options are: 'ascii', 'ASCII', 'ansi', 'ANSI', 'binary', 'BINARY', 'base64', 'BASE64', 'base64url',
|
|
511
|
-
// 'BASE64URL', 'hex', 'HEX', 'latin1', 'LATIN1', 'ucs-2', 'UCS-2', 'ucs2', 'UCS2', 'utf-8', 'UTF-8',
|
|
512
|
-
// 'utf8', 'UTF8', 'utf16le', 'UTF16LE'
|
|
513
385
|
responseEncoding: 'utf8', // default
|
|
514
386
|
|
|
515
387
|
// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
|
|
@@ -517,20 +389,17 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
517
389
|
|
|
518
390
|
// `xsrfHeaderName` is the name of the http header that carries the xsrf token value
|
|
519
391
|
xsrfHeaderName: 'X-XSRF-TOKEN', // default
|
|
520
|
-
|
|
521
|
-
// `undefined` (default) - set XSRF header only for the same origin requests
|
|
522
|
-
withXSRFToken: boolean | undefined | ((config: InternalAxiosRequestConfig) => boolean | undefined),
|
|
523
392
|
|
|
524
393
|
// `onUploadProgress` allows handling of progress events for uploads
|
|
525
|
-
// browser
|
|
526
|
-
onUploadProgress: function (
|
|
527
|
-
// Do whatever you want with the
|
|
394
|
+
// browser only
|
|
395
|
+
onUploadProgress: function (progressEvent) {
|
|
396
|
+
// Do whatever you want with the native progress event
|
|
528
397
|
},
|
|
529
398
|
|
|
530
399
|
// `onDownloadProgress` allows handling of progress events for downloads
|
|
531
|
-
// browser
|
|
532
|
-
onDownloadProgress: function (
|
|
533
|
-
// Do whatever you want with the
|
|
400
|
+
// browser only
|
|
401
|
+
onDownloadProgress: function (progressEvent) {
|
|
402
|
+
// Do whatever you want with the native progress event
|
|
534
403
|
},
|
|
535
404
|
|
|
536
405
|
// `maxContentLength` defines the max size of the http response content in bytes allowed in node.js
|
|
@@ -560,16 +429,13 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
560
429
|
if (options.hostname === "example.com") {
|
|
561
430
|
options.auth = "user:password";
|
|
562
431
|
}
|
|
563
|
-
}
|
|
432
|
+
};
|
|
564
433
|
|
|
565
434
|
// `socketPath` defines a UNIX Socket to be used in node.js.
|
|
566
435
|
// e.g. '/var/run/docker.sock' to send requests to the docker daemon.
|
|
567
436
|
// Only either `socketPath` or `proxy` can be specified.
|
|
568
437
|
// If both are specified, `socketPath` is used.
|
|
569
438
|
socketPath: null, // default
|
|
570
|
-
|
|
571
|
-
// `transport` determines the transport method that will be used to make the request. If defined, it will be used. Otherwise, if `maxRedirects` is 0, the default `http` or `https` library will be used, depending on the protocol specified in `protocol`. Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol, which can handle redirects.
|
|
572
|
-
transport: undefined, // default
|
|
573
439
|
|
|
574
440
|
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
|
575
441
|
// and https requests, respectively, in node.js. This allows options to be added like
|
|
@@ -587,11 +453,10 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
587
453
|
// supplies credentials.
|
|
588
454
|
// This will set an `Proxy-Authorization` header, overwriting any existing
|
|
589
455
|
// `Proxy-Authorization` custom headers you have set using `headers`.
|
|
590
|
-
// If the proxy server uses HTTPS, then you must set the protocol to `https`.
|
|
456
|
+
// If the proxy server uses HTTPS, then you must set the protocol to `https`.
|
|
591
457
|
proxy: {
|
|
592
458
|
protocol: 'https',
|
|
593
459
|
host: '127.0.0.1',
|
|
594
|
-
// hostname: '127.0.0.1' // Takes precedence over 'host' if both are defined
|
|
595
460
|
port: 9000,
|
|
596
461
|
auth: {
|
|
597
462
|
username: 'mikeymike',
|
|
@@ -607,11 +472,11 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
607
472
|
// an alternative way to cancel Axios requests using AbortController
|
|
608
473
|
signal: new AbortController().signal,
|
|
609
474
|
|
|
610
|
-
// `decompress` indicates whether or not the response body should be decompressed
|
|
611
|
-
// automatically. If set to `true` will also remove the 'content-encoding' header
|
|
475
|
+
// `decompress` indicates whether or not the response body should be decompressed
|
|
476
|
+
// automatically. If set to `true` will also remove the 'content-encoding' header
|
|
612
477
|
// from the responses objects of all decompressed responses
|
|
613
478
|
// - Node only (XHR cannot turn off decompression)
|
|
614
|
-
decompress: true
|
|
479
|
+
decompress: true // default
|
|
615
480
|
|
|
616
481
|
// `insecureHTTPParser` boolean.
|
|
617
482
|
// Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers.
|
|
@@ -619,7 +484,7 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
619
484
|
// Using the insecure parser should be avoided.
|
|
620
485
|
// see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback
|
|
621
486
|
// see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none
|
|
622
|
-
insecureHTTPParser: undefined
|
|
487
|
+
insecureHTTPParser: undefined // default
|
|
623
488
|
|
|
624
489
|
// transitional options for backward compatibility that may be removed in the newer versions
|
|
625
490
|
transitional: {
|
|
@@ -630,7 +495,7 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
630
495
|
|
|
631
496
|
// try to parse the response string as JSON even if `responseType` is not 'json'
|
|
632
497
|
forcedJSONParsing: true,
|
|
633
|
-
|
|
498
|
+
|
|
634
499
|
// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
|
|
635
500
|
clarifyTimeoutError: false,
|
|
636
501
|
},
|
|
@@ -638,20 +503,7 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
638
503
|
env: {
|
|
639
504
|
// The FormData class to be used to automatically serialize the payload into a FormData object
|
|
640
505
|
FormData: window?.FormData || global?.FormData
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
formSerializer: {
|
|
644
|
-
visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form values
|
|
645
|
-
dots: boolean; // use dots instead of brackets format
|
|
646
|
-
metaTokens: boolean; // keep special endings like {} in parameter key
|
|
647
|
-
indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes
|
|
648
|
-
},
|
|
649
|
-
|
|
650
|
-
// http adapter only (node.js)
|
|
651
|
-
maxRate: [
|
|
652
|
-
100 * 1024, // 100KB/s upload limit,
|
|
653
|
-
100 * 1024 // 100KB/s download limit
|
|
654
|
-
]
|
|
506
|
+
}
|
|
655
507
|
}
|
|
656
508
|
```
|
|
657
509
|
|
|
@@ -671,7 +523,7 @@ The response for a request contains the following information.
|
|
|
671
523
|
statusText: 'OK',
|
|
672
524
|
|
|
673
525
|
// `headers` the HTTP headers that the server responded with
|
|
674
|
-
// All header names are
|
|
526
|
+
// All header names are lower cased and can be accessed using the bracket notation.
|
|
675
527
|
// Example: `response.headers['content-type']`
|
|
676
528
|
headers: {},
|
|
677
529
|
|
|
@@ -730,7 +582,7 @@ instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
|
|
730
582
|
|
|
731
583
|
### Config order of precedence
|
|
732
584
|
|
|
733
|
-
Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults
|
|
585
|
+
Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example.
|
|
734
586
|
|
|
735
587
|
```js
|
|
736
588
|
// Create an instance using the config defaults provided by the library
|
|
@@ -780,15 +632,6 @@ const myInterceptor = axios.interceptors.request.use(function () {/*...*/});
|
|
|
780
632
|
axios.interceptors.request.eject(myInterceptor);
|
|
781
633
|
```
|
|
782
634
|
|
|
783
|
-
You can also clear all interceptors for requests or responses.
|
|
784
|
-
```js
|
|
785
|
-
const instance = axios.create();
|
|
786
|
-
instance.interceptors.request.use(function () {/*...*/});
|
|
787
|
-
instance.interceptors.request.clear(); // Removes interceptors from requests
|
|
788
|
-
instance.interceptors.response.use(function () {/*...*/});
|
|
789
|
-
instance.interceptors.response.clear(); // Removes interceptors from responses
|
|
790
|
-
```
|
|
791
|
-
|
|
792
635
|
You can add interceptors to a custom instance of axios.
|
|
793
636
|
|
|
794
637
|
```js
|
|
@@ -797,7 +640,7 @@ instance.interceptors.request.use(function () {/*...*/});
|
|
|
797
640
|
```
|
|
798
641
|
|
|
799
642
|
When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay
|
|
800
|
-
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for
|
|
643
|
+
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for
|
|
801
644
|
the interceptor and your request gets put on the bottom of the call stack). If your request interceptors are synchronous you can add a flag
|
|
802
645
|
to the options object that will tell axios to run the code synchronously and avoid any delays in request execution.
|
|
803
646
|
|
|
@@ -808,7 +651,7 @@ axios.interceptors.request.use(function (config) {
|
|
|
808
651
|
}, null, { synchronous: true });
|
|
809
652
|
```
|
|
810
653
|
|
|
811
|
-
If you want to execute a particular interceptor based on a runtime check,
|
|
654
|
+
If you want to execute a particular interceptor based on a runtime check,
|
|
812
655
|
you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return
|
|
813
656
|
of `runWhen` is `false`. The function will be called with the config
|
|
814
657
|
object (don't forget that you can bind your own arguments to it as well.) This can be handy when you have an
|
|
@@ -831,48 +674,16 @@ and when the response was fulfilled
|
|
|
831
674
|
- then each interceptor is executed
|
|
832
675
|
- then they are executed in the order they were added
|
|
833
676
|
- then only the last interceptor's result is returned
|
|
834
|
-
- then every interceptor receives the result of
|
|
677
|
+
- then every interceptor receives the result of it's predecessor
|
|
835
678
|
- and when the fulfillment-interceptor throws
|
|
836
679
|
- then the following fulfillment-interceptor is not called
|
|
837
680
|
- then the following rejection-interceptor is called
|
|
838
681
|
- once caught, another following fulfill-interceptor is called again (just like in a promise chain).
|
|
839
|
-
|
|
682
|
+
|
|
840
683
|
Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code.
|
|
841
684
|
|
|
842
|
-
## Error Types
|
|
843
|
-
|
|
844
|
-
There are many different axios error messages that can appear that can provide basic information about the specifics of the error and where opportunities may lie in debugging.
|
|
845
|
-
|
|
846
|
-
The general structure of axios errors is as follows:
|
|
847
|
-
| Property | Definition |
|
|
848
|
-
| -------- | ---------- |
|
|
849
|
-
| message | A quick summary of the error message and the status it failed with. |
|
|
850
|
-
| name | This defines where the error originated from. For axios, it will always be an 'AxiosError'. |
|
|
851
|
-
| stack | Provides the stack trace of the error. |
|
|
852
|
-
| config | An axios config object with specific instance configurations defined by the user from when the request was made |
|
|
853
|
-
| code | Represents an axios identified error. The table below lists out specific definitions for internal axios error. |
|
|
854
|
-
| status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings.
|
|
855
|
-
|
|
856
|
-
Below is a list of potential axios identified error
|
|
857
|
-
| Code | Definition |
|
|
858
|
-
| -------- | ---------- |
|
|
859
|
-
| ERR_BAD_OPTION_VALUE | Invalid or unsupported value provided in axios configuration. |
|
|
860
|
-
| ERR_BAD_OPTION | Invalid option provided in axios configuration. |
|
|
861
|
-
| ECONNABORTED | Request timed out due to exceeding timeout specified in axios configuration. |
|
|
862
|
-
| ETIMEDOUT | Request timed out due to exceeding default axios timelimit. |
|
|
863
|
-
| ERR_NETWORK | Network-related issue.
|
|
864
|
-
| ERR_FR_TOO_MANY_REDIRECTS | Request is redirected too many times; exceeds max redirects specified in axios configuration.
|
|
865
|
-
| ERR_DEPRECATED | Deprecated feature or method used in axios.
|
|
866
|
-
| ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format.
|
|
867
|
-
| ERR_BAD_REQUEST | Requested has unexpected format or missing required parameters. |
|
|
868
|
-
| ERR_CANCELED | Feature or method is canceled explicitly by the user.
|
|
869
|
-
| ERR_NOT_SUPPORT | Feature or method not supported in the current axios environment.
|
|
870
|
-
| ERR_INVALID_URL | Invalid URL provided for axios request.
|
|
871
|
-
|
|
872
685
|
## Handling Errors
|
|
873
686
|
|
|
874
|
-
the default behavior is to reject every response that returns with a status code that falls out of the range of 2xx and treat it as an error.
|
|
875
|
-
|
|
876
687
|
```js
|
|
877
688
|
axios.get('/user/12345')
|
|
878
689
|
.catch(function (error) {
|
|
@@ -895,7 +706,7 @@ axios.get('/user/12345')
|
|
|
895
706
|
});
|
|
896
707
|
```
|
|
897
708
|
|
|
898
|
-
Using the `validateStatus` config option, you can
|
|
709
|
+
Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error.
|
|
899
710
|
|
|
900
711
|
```js
|
|
901
712
|
axios.get('/user/12345', {
|
|
@@ -936,7 +747,7 @@ controller.abort()
|
|
|
936
747
|
|
|
937
748
|
You can also cancel a request using a *CancelToken*.
|
|
938
749
|
|
|
939
|
-
> The axios cancel token API is based on the withdrawn [
|
|
750
|
+
> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises).
|
|
940
751
|
|
|
941
752
|
> This API is deprecated since v0.22.0 and shouldn't be used in new projects
|
|
942
753
|
|
|
@@ -983,26 +794,27 @@ axios.get('/user/12345', {
|
|
|
983
794
|
cancel();
|
|
984
795
|
```
|
|
985
796
|
|
|
986
|
-
>
|
|
987
|
-
> If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make
|
|
797
|
+
> Note: you can cancel several requests with the same cancel token/abort controller.
|
|
798
|
+
> If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make real request.
|
|
988
799
|
|
|
989
800
|
> During the transition period, you can use both cancellation APIs, even for the same request:
|
|
990
801
|
|
|
991
|
-
## Using
|
|
802
|
+
## Using application/x-www-form-urlencoded format
|
|
803
|
+
|
|
804
|
+
By default, axios serializes JavaScript objects to `JSON`. To send data in the `application/x-www-form-urlencoded` format instead, you can use one of the following options.
|
|
992
805
|
|
|
993
|
-
###
|
|
806
|
+
### Browser
|
|
994
807
|
|
|
995
|
-
|
|
808
|
+
In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows:
|
|
996
809
|
|
|
997
810
|
```js
|
|
998
|
-
const params = new URLSearchParams(
|
|
999
|
-
params.append('
|
|
811
|
+
const params = new URLSearchParams();
|
|
812
|
+
params.append('param1', 'value1');
|
|
813
|
+
params.append('param2', 'value2');
|
|
1000
814
|
axios.post('/foo', params);
|
|
1001
815
|
```
|
|
1002
816
|
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
For compatibility with very old browsers, there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment).
|
|
817
|
+
> Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment).
|
|
1006
818
|
|
|
1007
819
|
Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library:
|
|
1008
820
|
|
|
@@ -1025,98 +837,35 @@ const options = {
|
|
|
1025
837
|
axios(options);
|
|
1026
838
|
```
|
|
1027
839
|
|
|
1028
|
-
###
|
|
840
|
+
### Node.js
|
|
1029
841
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
```js
|
|
1033
|
-
const querystring = require('querystring');
|
|
1034
|
-
axios.post('https://something.com/', querystring.stringify({ foo: 'bar' }));
|
|
1035
|
-
```
|
|
1036
|
-
|
|
1037
|
-
You can also use the [`qs`](https://github.com/ljharb/qs) library.
|
|
1038
|
-
|
|
1039
|
-
> **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.
|
|
1040
|
-
|
|
1041
|
-
### 🆕 Automatic serialization to URLSearchParams
|
|
1042
|
-
|
|
1043
|
-
Axios will automatically serialize the data object to urlencoded format if the content-type header is set to "application/x-www-form-urlencoded".
|
|
1044
|
-
|
|
1045
|
-
```js
|
|
1046
|
-
const data = {
|
|
1047
|
-
x: 1,
|
|
1048
|
-
arr: [1, 2, 3],
|
|
1049
|
-
arr2: [1, [2], 3],
|
|
1050
|
-
users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}],
|
|
1051
|
-
};
|
|
1052
|
-
|
|
1053
|
-
await axios.postForm('https://postman-echo.com/post', data,
|
|
1054
|
-
{headers: {'content-type': 'application/x-www-form-urlencoded'}}
|
|
1055
|
-
);
|
|
1056
|
-
```
|
|
842
|
+
#### Query string
|
|
1057
843
|
|
|
1058
|
-
|
|
844
|
+
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
|
|
1059
845
|
|
|
1060
846
|
```js
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
'arr[]': [ '1', '2', '3' ],
|
|
1064
|
-
'arr2[0]': '1',
|
|
1065
|
-
'arr2[1][0]': '2',
|
|
1066
|
-
'arr2[2]': '3',
|
|
1067
|
-
'arr3[]': [ '1', '2', '3' ],
|
|
1068
|
-
'users[0][name]': 'Peter',
|
|
1069
|
-
'users[0][surname]': 'griffin',
|
|
1070
|
-
'users[1][name]': 'Thomas',
|
|
1071
|
-
'users[1][surname]': 'Anderson'
|
|
1072
|
-
}
|
|
1073
|
-
````
|
|
1074
|
-
|
|
1075
|
-
If your backend body-parser (like `body-parser` of `express.js`) supports nested objects decoding, you will get the same object on the server-side automatically
|
|
1076
|
-
|
|
1077
|
-
```js
|
|
1078
|
-
var app = express();
|
|
1079
|
-
|
|
1080
|
-
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
|
|
1081
|
-
|
|
1082
|
-
app.post('/', function (req, res, next) {
|
|
1083
|
-
// echo body as JSON
|
|
1084
|
-
res.send(JSON.stringify(req.body));
|
|
1085
|
-
});
|
|
1086
|
-
|
|
1087
|
-
server = app.listen(3000);
|
|
847
|
+
const querystring = require('querystring');
|
|
848
|
+
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
|
|
1088
849
|
```
|
|
1089
850
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
### FormData
|
|
1093
|
-
|
|
1094
|
-
To send the data as a `multipart/formdata` you need to pass a formData instance as a payload.
|
|
1095
|
-
Setting the `Content-Type` header is not required as Axios guesses it based on the payload type.
|
|
851
|
+
or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows:
|
|
1096
852
|
|
|
1097
853
|
```js
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
axios.post('https://httpbin.org/post', formData);
|
|
854
|
+
const url = require('url');
|
|
855
|
+
const params = new url.URLSearchParams({ foo: 'bar' });
|
|
856
|
+
axios.post('http://something.com/', params.toString());
|
|
1102
857
|
```
|
|
1103
858
|
|
|
1104
|
-
|
|
859
|
+
You can also use the [`qs`](https://github.com/ljharb/qs) library.
|
|
1105
860
|
|
|
1106
|
-
|
|
1107
|
-
|
|
861
|
+
> NOTE:
|
|
862
|
+
> 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.
|
|
1108
863
|
|
|
1109
|
-
|
|
1110
|
-
form.append('my_field', 'my value');
|
|
1111
|
-
form.append('my_buffer', new Buffer(10));
|
|
1112
|
-
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
|
1113
|
-
|
|
1114
|
-
axios.post('https://example.com', form)
|
|
1115
|
-
```
|
|
864
|
+
#### Form data
|
|
1116
865
|
|
|
1117
|
-
|
|
866
|
+
##### 🆕 Automatic serialization
|
|
1118
867
|
|
|
1119
|
-
Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type`
|
|
868
|
+
Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type`
|
|
1120
869
|
header is set to `multipart/form-data`.
|
|
1121
870
|
|
|
1122
871
|
The following request will submit the data in a FormData format (Browser & Node.js):
|
|
@@ -1128,7 +877,7 @@ axios.post('https://httpbin.org/post', {x: 1}, {
|
|
|
1128
877
|
headers: {
|
|
1129
878
|
'Content-Type': 'multipart/form-data'
|
|
1130
879
|
}
|
|
1131
|
-
}).then(({data})
|
|
880
|
+
}).then(({data})=> console.log(data));
|
|
1132
881
|
```
|
|
1133
882
|
|
|
1134
883
|
In the `node.js` build, the ([`form-data`](https://github.com/form-data/form-data)) polyfill is used by default.
|
|
@@ -1137,520 +886,72 @@ You can overload the FormData class by setting the `env.FormData` config variabl
|
|
|
1137
886
|
but you probably won't need it in most cases:
|
|
1138
887
|
|
|
1139
888
|
```js
|
|
1140
|
-
const axios
|
|
889
|
+
const axios= require('axios');
|
|
1141
890
|
var FormData = require('form-data');
|
|
1142
891
|
|
|
1143
892
|
axios.post('https://httpbin.org/post', {x: 1, buf: new Buffer(10)}, {
|
|
1144
893
|
headers: {
|
|
1145
894
|
'Content-Type': 'multipart/form-data'
|
|
1146
895
|
}
|
|
1147
|
-
}).then(({data})
|
|
896
|
+
}).then(({data})=> console.log(data));
|
|
1148
897
|
```
|
|
1149
898
|
|
|
1150
899
|
Axios FormData serializer supports some special endings to perform the following operations:
|
|
1151
900
|
|
|
1152
901
|
- `{}` - serialize the value with JSON.stringify
|
|
1153
|
-
- `[]` - unwrap the array
|
|
1154
|
-
|
|
1155
|
-
> **Note**: unwrap/expand operation will be used by default on arrays and FileList objects
|
|
1156
|
-
|
|
1157
|
-
FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases:
|
|
1158
|
-
|
|
1159
|
-
- `visitor: Function` - user-defined visitor function that will be called recursively to serialize the data object
|
|
1160
|
-
to a `FormData` object by following custom rules.
|
|
1161
|
-
|
|
1162
|
-
- `dots: boolean = false` - use dot notation instead of brackets to serialize arrays and objects;
|
|
1163
|
-
|
|
1164
|
-
- `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key.
|
|
1165
|
-
The back-end body-parser could potentially use this meta-information to automatically parse the value as JSON.
|
|
1166
|
-
|
|
1167
|
-
- `indexes: null|false|true = false` - controls how indexes will be added to unwrapped keys of `flat` array-like objects
|
|
1168
|
-
|
|
1169
|
-
- `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`)
|
|
1170
|
-
- `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`)
|
|
1171
|
-
- `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`)
|
|
1172
|
-
|
|
1173
|
-
Let's say we have an object like this one:
|
|
1174
|
-
|
|
1175
|
-
```js
|
|
1176
|
-
const obj = {
|
|
1177
|
-
x: 1,
|
|
1178
|
-
arr: [1, 2, 3],
|
|
1179
|
-
arr2: [1, [2], 3],
|
|
1180
|
-
users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}],
|
|
1181
|
-
'obj2{}': [{x:1}]
|
|
1182
|
-
};
|
|
1183
|
-
```
|
|
1184
|
-
|
|
1185
|
-
The following steps will be executed by the Axios serializer internally:
|
|
1186
|
-
|
|
1187
|
-
```js
|
|
1188
|
-
const formData = new FormData();
|
|
1189
|
-
formData.append('x', '1');
|
|
1190
|
-
formData.append('arr[]', '1');
|
|
1191
|
-
formData.append('arr[]', '2');
|
|
1192
|
-
formData.append('arr[]', '3');
|
|
1193
|
-
formData.append('arr2[0]', '1');
|
|
1194
|
-
formData.append('arr2[1][0]', '2');
|
|
1195
|
-
formData.append('arr2[2]', '3');
|
|
1196
|
-
formData.append('users[0][name]', 'Peter');
|
|
1197
|
-
formData.append('users[0][surname]', 'Griffin');
|
|
1198
|
-
formData.append('users[1][name]', 'Thomas');
|
|
1199
|
-
formData.append('users[1][surname]', 'Anderson');
|
|
1200
|
-
formData.append('obj2{}', '[{"x":1}]');
|
|
1201
|
-
```
|
|
1202
|
-
|
|
1203
|
-
Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm`
|
|
1204
|
-
which are just the corresponding http methods with the `Content-Type` header preset to `multipart/form-data`.
|
|
1205
|
-
|
|
1206
|
-
## Files Posting
|
|
1207
|
-
|
|
1208
|
-
You can easily submit a single file:
|
|
1209
|
-
|
|
1210
|
-
```js
|
|
1211
|
-
await axios.postForm('https://httpbin.org/post', {
|
|
1212
|
-
'myVar' : 'foo',
|
|
1213
|
-
'file': document.querySelector('#fileInput').files[0]
|
|
1214
|
-
});
|
|
1215
|
-
```
|
|
1216
|
-
|
|
1217
|
-
or multiple files as `multipart/form-data`:
|
|
902
|
+
- `[]` - unwrap the array like object as separate fields with the same key
|
|
1218
903
|
|
|
1219
904
|
```js
|
|
1220
|
-
|
|
1221
|
-
'files[]': document.querySelector('#fileInput').files
|
|
1222
|
-
});
|
|
1223
|
-
```
|
|
1224
|
-
|
|
1225
|
-
`FileList` object can be passed directly:
|
|
905
|
+
const axios= require('axios');
|
|
1226
906
|
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
All files will be sent with the same field names: `files[]`.
|
|
1232
|
-
|
|
1233
|
-
## 🆕 HTML Form Posting (browser)
|
|
1234
|
-
|
|
1235
|
-
Pass HTML Form element as a payload to submit it as `multipart/form-data` content.
|
|
1236
|
-
|
|
1237
|
-
```js
|
|
1238
|
-
await axios.postForm('https://httpbin.org/post', document.querySelector('#htmlForm'));
|
|
1239
|
-
```
|
|
1240
|
-
|
|
1241
|
-
`FormData` and `HTMLForm` objects can also be posted as `JSON` by explicitly setting the `Content-Type` header to `application/json`:
|
|
1242
|
-
|
|
1243
|
-
```js
|
|
1244
|
-
await axios.post('https://httpbin.org/post', document.querySelector('#htmlForm'), {
|
|
907
|
+
axios.post('https://httpbin.org/post', {
|
|
908
|
+
'myObj{}': {x: 1, s: "foo"},
|
|
909
|
+
'files[]': document.querySelector('#fileInput').files
|
|
910
|
+
}, {
|
|
1245
911
|
headers: {
|
|
1246
|
-
'Content-Type': '
|
|
912
|
+
'Content-Type': 'multipart/form-data'
|
|
1247
913
|
}
|
|
1248
|
-
})
|
|
914
|
+
}).then(({data})=> console.log(data));
|
|
1249
915
|
```
|
|
1250
916
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
```html
|
|
1254
|
-
<form id="form">
|
|
1255
|
-
<input type="text" name="foo" value="1">
|
|
1256
|
-
<input type="text" name="deep.prop" value="2">
|
|
1257
|
-
<input type="text" name="deep prop spaced" value="3">
|
|
1258
|
-
<input type="text" name="baz" value="4">
|
|
1259
|
-
<input type="text" name="baz" value="5">
|
|
1260
|
-
|
|
1261
|
-
<select name="user.age">
|
|
1262
|
-
<option value="value1">Value 1</option>
|
|
1263
|
-
<option value="value2" selected>Value 2</option>
|
|
1264
|
-
<option value="value3">Value 3</option>
|
|
1265
|
-
</select>
|
|
1266
|
-
|
|
1267
|
-
<input type="submit" value="Save">
|
|
1268
|
-
</form>
|
|
1269
|
-
```
|
|
917
|
+
Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm`
|
|
918
|
+
which are just the corresponding http methods with a header preset: `Content-Type`: `multipart/form-data`.
|
|
1270
919
|
|
|
1271
|
-
|
|
920
|
+
FileList object can be passed directly:
|
|
1272
921
|
|
|
1273
922
|
```js
|
|
1274
|
-
|
|
1275
|
-
"foo": "1",
|
|
1276
|
-
"deep": {
|
|
1277
|
-
"prop": {
|
|
1278
|
-
"spaced": "3"
|
|
1279
|
-
}
|
|
1280
|
-
},
|
|
1281
|
-
"baz": [
|
|
1282
|
-
"4",
|
|
1283
|
-
"5"
|
|
1284
|
-
],
|
|
1285
|
-
"user": {
|
|
1286
|
-
"age": "value2"
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
````
|
|
1290
|
-
|
|
1291
|
-
Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported.
|
|
1292
|
-
|
|
1293
|
-
## 🆕 Progress capturing
|
|
1294
|
-
|
|
1295
|
-
Axios supports both browser and node environments to capture request upload/download progress.
|
|
1296
|
-
The frequency of progress events is forced to be limited to `3` times per second.
|
|
1297
|
-
|
|
1298
|
-
```js
|
|
1299
|
-
await axios.post(url, data, {
|
|
1300
|
-
onUploadProgress: function (axiosProgressEvent) {
|
|
1301
|
-
/*{
|
|
1302
|
-
loaded: number;
|
|
1303
|
-
total?: number;
|
|
1304
|
-
progress?: number; // in range [0..1]
|
|
1305
|
-
bytes: number; // how many bytes have been transferred since the last trigger (delta)
|
|
1306
|
-
estimated?: number; // estimated time in seconds
|
|
1307
|
-
rate?: number; // upload speed in bytes
|
|
1308
|
-
upload: true; // upload sign
|
|
1309
|
-
}*/
|
|
1310
|
-
},
|
|
1311
|
-
|
|
1312
|
-
onDownloadProgress: function (axiosProgressEvent) {
|
|
1313
|
-
/*{
|
|
1314
|
-
loaded: number;
|
|
1315
|
-
total?: number;
|
|
1316
|
-
progress?: number;
|
|
1317
|
-
bytes: number;
|
|
1318
|
-
estimated?: number;
|
|
1319
|
-
rate?: number; // download speed in bytes
|
|
1320
|
-
download: true; // download sign
|
|
1321
|
-
}*/
|
|
1322
|
-
}
|
|
1323
|
-
});
|
|
923
|
+
await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files)
|
|
1324
924
|
```
|
|
1325
925
|
|
|
1326
|
-
|
|
926
|
+
All files will be sent with the same field names: `files[]`;
|
|
1327
927
|
|
|
1328
|
-
|
|
1329
|
-
const {data} = await axios.post(SERVER_URL, readableStream, {
|
|
1330
|
-
onUploadProgress: ({progress}) => {
|
|
1331
|
-
console.log((progress * 100).toFixed(2));
|
|
1332
|
-
},
|
|
928
|
+
##### Manual FormData passing
|
|
1333
929
|
|
|
1334
|
-
|
|
1335
|
-
'Content-Length': contentLength
|
|
1336
|
-
},
|
|
1337
|
-
|
|
1338
|
-
maxRedirects: 0 // avoid buffering the entire stream
|
|
1339
|
-
});
|
|
1340
|
-
````
|
|
1341
|
-
|
|
1342
|
-
> **Note:**
|
|
1343
|
-
> Capturing FormData upload progress is not currently supported in node.js environments.
|
|
1344
|
-
|
|
1345
|
-
> **⚠️ Warning**
|
|
1346
|
-
> It is recommended to disable redirects by setting maxRedirects: 0 to upload the stream in the **node.js** environment,
|
|
1347
|
-
> as follow-redirects package will buffer the entire stream in RAM without following the "backpressure" algorithm.
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
## 🆕 Rate limiting
|
|
1351
|
-
|
|
1352
|
-
Download and upload rate limits can only be set for the http adapter (node.js):
|
|
1353
|
-
|
|
1354
|
-
```js
|
|
1355
|
-
const {data} = await axios.post(LOCAL_SERVER_URL, myBuffer, {
|
|
1356
|
-
onUploadProgress: ({progress, rate}) => {
|
|
1357
|
-
console.log(`Upload [${(progress*100).toFixed(2)}%]: ${(rate / 1024).toFixed(2)}KB/s`)
|
|
1358
|
-
},
|
|
1359
|
-
|
|
1360
|
-
maxRate: [100 * 1024], // 100KB/s limit
|
|
1361
|
-
});
|
|
1362
|
-
```
|
|
1363
|
-
|
|
1364
|
-
## 🆕 AxiosHeaders
|
|
1365
|
-
|
|
1366
|
-
Axios has its own `AxiosHeaders` class to manipulate headers using a Map-like API that guarantees caseless work.
|
|
1367
|
-
Although HTTP is case-insensitive in headers, Axios will retain the case of the original header for stylistic reasons
|
|
1368
|
-
and for a workaround when servers mistakenly consider the header's case.
|
|
1369
|
-
The old approach of directly manipulating headers object is still available, but deprecated and not recommended for future usage.
|
|
1370
|
-
|
|
1371
|
-
### Working with headers
|
|
1372
|
-
|
|
1373
|
-
An AxiosHeaders object instance can contain different types of internal values. that control setting and merging logic.
|
|
1374
|
-
The final headers object with string values is obtained by Axios by calling the `toJSON` method.
|
|
1375
|
-
|
|
1376
|
-
> Note: By JSON here we mean an object consisting only of string values intended to be sent over the network.
|
|
1377
|
-
|
|
1378
|
-
The header value can be one of the following types:
|
|
1379
|
-
- `string` - normal string value that will be sent to the server
|
|
1380
|
-
- `null` - skip header when rendering to JSON
|
|
1381
|
-
- `false` - skip header when rendering to JSON, additionally indicates that `set` method must be called with `rewrite` option set to `true`
|
|
1382
|
-
to overwrite this value (Axios uses this internally to allow users to opt out of installing certain headers like `User-Agent` or `Content-Type`)
|
|
1383
|
-
- `undefined` - value is not set
|
|
1384
|
-
|
|
1385
|
-
> Note: The header value is considered set if it is not equal to undefined.
|
|
1386
|
-
|
|
1387
|
-
The headers object is always initialized inside interceptors and transformers:
|
|
1388
|
-
|
|
1389
|
-
```ts
|
|
1390
|
-
axios.interceptors.request.use((request: InternalAxiosRequestConfig) => {
|
|
1391
|
-
request.headers.set('My-header', 'value');
|
|
1392
|
-
|
|
1393
|
-
request.headers.set({
|
|
1394
|
-
"My-set-header1": "my-set-value1",
|
|
1395
|
-
"My-set-header2": "my-set-value2"
|
|
1396
|
-
});
|
|
1397
|
-
|
|
1398
|
-
request.headers.set('User-Agent', false); // disable subsequent setting the header by Axios
|
|
1399
|
-
|
|
1400
|
-
request.headers.setContentType('text/plain');
|
|
1401
|
-
|
|
1402
|
-
request.headers['My-set-header2'] = 'newValue' // direct access is deprecated
|
|
1403
|
-
|
|
1404
|
-
return request;
|
|
1405
|
-
}
|
|
1406
|
-
);
|
|
1407
|
-
````
|
|
1408
|
-
|
|
1409
|
-
You can iterate over an `AxiosHeaders` instance using a `for...of` statement:
|
|
1410
|
-
|
|
1411
|
-
````js
|
|
1412
|
-
const headers = new AxiosHeaders({
|
|
1413
|
-
foo: '1',
|
|
1414
|
-
bar: '2',
|
|
1415
|
-
baz: '3'
|
|
1416
|
-
});
|
|
1417
|
-
|
|
1418
|
-
for(const [header, value] of headers) {
|
|
1419
|
-
console.log(header, value);
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
// foo 1
|
|
1423
|
-
// bar 2
|
|
1424
|
-
// baz 3
|
|
1425
|
-
````
|
|
1426
|
-
|
|
1427
|
-
### new AxiosHeaders(headers?)
|
|
1428
|
-
|
|
1429
|
-
Constructs a new `AxiosHeaders` instance.
|
|
1430
|
-
|
|
1431
|
-
```
|
|
1432
|
-
constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
|
|
1433
|
-
```
|
|
1434
|
-
|
|
1435
|
-
If the headers object is a string, it will be parsed as RAW HTTP headers.
|
|
1436
|
-
|
|
1437
|
-
````js
|
|
1438
|
-
const headers = new AxiosHeaders(`
|
|
1439
|
-
Host: www.bing.com
|
|
1440
|
-
User-Agent: curl/7.54.0
|
|
1441
|
-
Accept: */*`);
|
|
1442
|
-
|
|
1443
|
-
console.log(headers);
|
|
1444
|
-
|
|
1445
|
-
// Object [AxiosHeaders] {
|
|
1446
|
-
// host: 'www.bing.com',
|
|
1447
|
-
// 'user-agent': 'curl/7.54.0',
|
|
1448
|
-
// accept: '*/*'
|
|
1449
|
-
// }
|
|
1450
|
-
````
|
|
1451
|
-
|
|
1452
|
-
### AxiosHeaders#set
|
|
1453
|
-
|
|
1454
|
-
```ts
|
|
1455
|
-
set(headerName, value: Axios, rewrite?: boolean);
|
|
1456
|
-
set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean);
|
|
1457
|
-
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean);
|
|
1458
|
-
```
|
|
1459
|
-
|
|
1460
|
-
The `rewrite` argument controls the overwriting behavior:
|
|
1461
|
-
- `false` - do not overwrite if header's value is set (is not `undefined`)
|
|
1462
|
-
- `undefined` (default) - overwrite the header unless its value is set to `false`
|
|
1463
|
-
- `true` - rewrite anyway
|
|
1464
|
-
|
|
1465
|
-
The option can also accept a user-defined function that determines whether the value should be overwritten or not.
|
|
1466
|
-
|
|
1467
|
-
Returns `this`.
|
|
1468
|
-
|
|
1469
|
-
### AxiosHeaders#get(header)
|
|
1470
|
-
|
|
1471
|
-
```
|
|
1472
|
-
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
|
|
1473
|
-
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
|
1474
|
-
````
|
|
1475
|
-
|
|
1476
|
-
Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`,
|
|
1477
|
-
matcher function or internal key-value parser.
|
|
1478
|
-
|
|
1479
|
-
```ts
|
|
1480
|
-
const headers = new AxiosHeaders({
|
|
1481
|
-
'Content-Type': 'multipart/form-data; boundary=Asrf456BGe4h'
|
|
1482
|
-
});
|
|
1483
|
-
|
|
1484
|
-
console.log(headers.get('Content-Type'));
|
|
1485
|
-
// multipart/form-data; boundary=Asrf456BGe4h
|
|
1486
|
-
|
|
1487
|
-
console.log(headers.get('Content-Type', true)); // parse key-value pairs from a string separated with \s,;= delimiters:
|
|
1488
|
-
// [Object: null prototype] {
|
|
1489
|
-
// 'multipart/form-data': undefined,
|
|
1490
|
-
// boundary: 'Asrf456BGe4h'
|
|
1491
|
-
// }
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
console.log(headers.get('Content-Type', (value, name, headers) => {
|
|
1495
|
-
return String(value).replace(/a/g, 'ZZZ');
|
|
1496
|
-
}));
|
|
1497
|
-
// multipZZZrt/form-dZZZtZZZ; boundZZZry=Asrf456BGe4h
|
|
1498
|
-
|
|
1499
|
-
console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]);
|
|
1500
|
-
// boundary=Asrf456BGe4h
|
|
1501
|
-
|
|
1502
|
-
```
|
|
1503
|
-
|
|
1504
|
-
Returns the value of the header.
|
|
1505
|
-
|
|
1506
|
-
### AxiosHeaders#has(header, matcher?)
|
|
1507
|
-
|
|
1508
|
-
```
|
|
1509
|
-
has(header: string, matcher?: AxiosHeaderMatcher): boolean;
|
|
1510
|
-
```
|
|
1511
|
-
|
|
1512
|
-
Returns `true` if the header is set (has no `undefined` value).
|
|
1513
|
-
|
|
1514
|
-
### AxiosHeaders#delete(header, matcher?)
|
|
1515
|
-
|
|
1516
|
-
```
|
|
1517
|
-
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
|
1518
|
-
```
|
|
1519
|
-
|
|
1520
|
-
Returns `true` if at least one header has been removed.
|
|
1521
|
-
|
|
1522
|
-
### AxiosHeaders#clear(matcher?)
|
|
1523
|
-
|
|
1524
|
-
```
|
|
1525
|
-
clear(matcher?: AxiosHeaderMatcher): boolean;
|
|
1526
|
-
```
|
|
1527
|
-
|
|
1528
|
-
Removes all headers.
|
|
1529
|
-
Unlike the `delete` method matcher, this optional matcher will be used to match against the header name rather than the value.
|
|
1530
|
-
|
|
1531
|
-
```ts
|
|
1532
|
-
const headers = new AxiosHeaders({
|
|
1533
|
-
'foo': '1',
|
|
1534
|
-
'x-foo': '2',
|
|
1535
|
-
'x-bar': '3',
|
|
1536
|
-
});
|
|
1537
|
-
|
|
1538
|
-
console.log(headers.clear(/^x-/)); // true
|
|
1539
|
-
|
|
1540
|
-
console.log(headers.toJSON()); // [Object: null prototype] { foo: '1' }
|
|
1541
|
-
```
|
|
1542
|
-
|
|
1543
|
-
Returns `true` if at least one header has been cleared.
|
|
1544
|
-
|
|
1545
|
-
### AxiosHeaders#normalize(format);
|
|
1546
|
-
|
|
1547
|
-
If the headers object was changed directly, it can have duplicates with the same name but in different cases.
|
|
1548
|
-
This method normalizes the headers object by combining duplicate keys into one.
|
|
1549
|
-
Axios uses this method internally after calling each interceptor.
|
|
1550
|
-
Set `format` to true for converting headers name to lowercase and capitalize the initial letters (`cOntEnt-type` => `Content-Type`)
|
|
1551
|
-
|
|
1552
|
-
```js
|
|
1553
|
-
const headers = new AxiosHeaders({
|
|
1554
|
-
'foo': '1',
|
|
1555
|
-
});
|
|
1556
|
-
|
|
1557
|
-
headers.Foo = '2';
|
|
1558
|
-
headers.FOO = '3';
|
|
1559
|
-
|
|
1560
|
-
console.log(headers.toJSON()); // [Object: null prototype] { foo: '1', Foo: '2', FOO: '3' }
|
|
1561
|
-
console.log(headers.normalize().toJSON()); // [Object: null prototype] { foo: '3' }
|
|
1562
|
-
console.log(headers.normalize(true).toJSON()); // [Object: null prototype] { Foo: '3' }
|
|
1563
|
-
```
|
|
1564
|
-
|
|
1565
|
-
Returns `this`.
|
|
1566
|
-
|
|
1567
|
-
### AxiosHeaders#concat(...targets)
|
|
1568
|
-
|
|
1569
|
-
```
|
|
1570
|
-
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
|
1571
|
-
```
|
|
1572
|
-
|
|
1573
|
-
Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, it will be parsed as RAW HTTP headers.
|
|
1574
|
-
|
|
1575
|
-
Returns a new `AxiosHeaders` instance.
|
|
1576
|
-
|
|
1577
|
-
### AxiosHeaders#toJSON(asStrings?)
|
|
1578
|
-
|
|
1579
|
-
````
|
|
1580
|
-
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
|
1581
|
-
````
|
|
1582
|
-
|
|
1583
|
-
Resolve all internal headers values into a new null prototype object.
|
|
1584
|
-
Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas.
|
|
1585
|
-
|
|
1586
|
-
### AxiosHeaders.from(thing?)
|
|
1587
|
-
|
|
1588
|
-
````
|
|
1589
|
-
from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
|
|
1590
|
-
````
|
|
1591
|
-
|
|
1592
|
-
Returns a new `AxiosHeaders` instance created from the raw headers passed in,
|
|
1593
|
-
or simply returns the given headers object if it's an `AxiosHeaders` instance.
|
|
1594
|
-
|
|
1595
|
-
### AxiosHeaders.concat(...targets)
|
|
1596
|
-
|
|
1597
|
-
````
|
|
1598
|
-
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
|
|
1599
|
-
````
|
|
1600
|
-
|
|
1601
|
-
Returns a new `AxiosHeaders` instance created by merging the target objects.
|
|
1602
|
-
|
|
1603
|
-
### Shortcuts
|
|
1604
|
-
|
|
1605
|
-
The following shortcuts are available:
|
|
1606
|
-
|
|
1607
|
-
- `setContentType`, `getContentType`, `hasContentType`
|
|
1608
|
-
|
|
1609
|
-
- `setContentLength`, `getContentLength`, `hasContentLength`
|
|
1610
|
-
|
|
1611
|
-
- `setAccept`, `getAccept`, `hasAccept`
|
|
1612
|
-
|
|
1613
|
-
- `setUserAgent`, `getUserAgent`, `hasUserAgent`
|
|
1614
|
-
|
|
1615
|
-
- `setContentEncoding`, `getContentEncoding`, `hasContentEncoding`
|
|
1616
|
-
|
|
1617
|
-
## 🔥 Fetch adapter
|
|
1618
|
-
|
|
1619
|
-
Fetch adapter was introduced in `v1.7.0`. By default, it will be used if `xhr` and `http` adapters are not available in the build,
|
|
1620
|
-
or not supported by the environment.
|
|
1621
|
-
To use it by default, it must be selected explicitly:
|
|
1622
|
-
|
|
1623
|
-
```js
|
|
1624
|
-
const {data} = axios.get(url, {
|
|
1625
|
-
adapter: 'fetch' // by default ['xhr', 'http', 'fetch']
|
|
1626
|
-
})
|
|
1627
|
-
```
|
|
1628
|
-
|
|
1629
|
-
You can create a separate instance for this:
|
|
930
|
+
In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows:
|
|
1630
931
|
|
|
1631
932
|
```js
|
|
1632
|
-
const
|
|
1633
|
-
|
|
1634
|
-
|
|
933
|
+
const FormData = require('form-data');
|
|
934
|
+
|
|
935
|
+
const form = new FormData();
|
|
936
|
+
form.append('my_field', 'my value');
|
|
937
|
+
form.append('my_buffer', new Buffer(10));
|
|
938
|
+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
|
1635
939
|
|
|
1636
|
-
|
|
940
|
+
axios.post('https://example.com', form)
|
|
1637
941
|
```
|
|
1638
942
|
|
|
1639
|
-
The adapter supports the same functionality as `xhr` adapter, **including upload and download progress capturing**.
|
|
1640
|
-
Also, it supports additional response types such as `stream` and `formdata` (if supported by the environment).
|
|
1641
|
-
|
|
1642
943
|
## Semver
|
|
1643
944
|
|
|
1644
945
|
Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes.
|
|
1645
946
|
|
|
1646
947
|
## Promises
|
|
1647
948
|
|
|
1648
|
-
axios depends on a native ES6 Promise implementation to be [supported](
|
|
949
|
+
axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises).
|
|
1649
950
|
If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
|
|
1650
951
|
|
|
1651
952
|
## TypeScript
|
|
1652
953
|
|
|
1653
|
-
axios includes [TypeScript](
|
|
954
|
+
axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors.
|
|
1654
955
|
|
|
1655
956
|
```typescript
|
|
1656
957
|
let user: User = null;
|
|
@@ -1666,25 +967,20 @@ try {
|
|
|
1666
967
|
}
|
|
1667
968
|
```
|
|
1668
969
|
|
|
1669
|
-
Because axios dual publishes with an ESM default export and a CJS `module.exports`, there are some caveats.
|
|
1670
|
-
The recommended setting is to use `"moduleResolution": "node16"` (this is implied by `"module": "node16"`). Note that this requires TypeScript 4.7 or greater.
|
|
1671
|
-
If use ESM, your settings should be fine.
|
|
1672
|
-
If you compile TypeScript to CJS and you can’t use `"moduleResolution": "node 16"`, you have to enable `esModuleInterop`.
|
|
1673
|
-
If you use TypeScript to type check CJS JavaScript code, your only option is to use `"moduleResolution": "node16"`.
|
|
1674
|
-
|
|
1675
970
|
## Online one-click setup
|
|
1676
971
|
|
|
1677
|
-
You can use Gitpod
|
|
972
|
+
You can use Gitpod an online IDE(which is free for Open Source) for contributing or running the examples online.
|
|
1678
973
|
|
|
1679
|
-
[](https://gitpod.io/#https://github.com/axios/axios/blob/
|
|
974
|
+
[](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js)
|
|
1680
975
|
|
|
1681
976
|
|
|
1682
977
|
## Resources
|
|
1683
978
|
|
|
1684
|
-
* [Changelog](https://github.com/axios/axios/blob/
|
|
1685
|
-
* [
|
|
1686
|
-
* [
|
|
1687
|
-
* [
|
|
979
|
+
* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
|
|
980
|
+
* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md)
|
|
981
|
+
* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md)
|
|
982
|
+
* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md)
|
|
983
|
+
* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md)
|
|
1688
984
|
|
|
1689
985
|
## Credits
|
|
1690
986
|
|