youtube-downloader-by-ahmad 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.bin/sshpk-conv +12 -0
- package/.bin/sshpk-conv.cmd +17 -0
- package/.bin/sshpk-conv.ps1 +28 -0
- package/.bin/sshpk-sign +12 -0
- package/.bin/sshpk-sign.cmd +17 -0
- package/.bin/sshpk-sign.ps1 +28 -0
- package/.bin/sshpk-verify +12 -0
- package/.bin/sshpk-verify.cmd +17 -0
- package/.bin/sshpk-verify.ps1 +28 -0
- package/.bin/uuid +12 -0
- package/.bin/uuid.cmd +17 -0
- package/.bin/uuid.ps1 +28 -0
- package/ajv/.tonic_example.js +20 -0
- package/ajv/LICENSE +22 -0
- package/ajv/README.md +1497 -0
- package/ajv/dist/ajv.bundle.js +7189 -0
- package/ajv/dist/ajv.min.js +3 -0
- package/ajv/dist/ajv.min.js.map +1 -0
- package/ajv/lib/ajv.d.ts +397 -0
- package/ajv/lib/ajv.js +506 -0
- package/ajv/lib/cache.js +26 -0
- package/ajv/lib/compile/async.js +90 -0
- package/ajv/lib/compile/equal.js +5 -0
- package/ajv/lib/compile/error_classes.js +34 -0
- package/ajv/lib/compile/formats.js +142 -0
- package/ajv/lib/compile/index.js +387 -0
- package/ajv/lib/compile/resolve.js +270 -0
- package/ajv/lib/compile/rules.js +66 -0
- package/ajv/lib/compile/schema_obj.js +9 -0
- package/ajv/lib/compile/ucs2length.js +20 -0
- package/ajv/lib/compile/util.js +239 -0
- package/ajv/lib/data.js +49 -0
- package/ajv/lib/definition_schema.js +37 -0
- package/ajv/lib/dot/_limit.jst +113 -0
- package/ajv/lib/dot/_limitItems.jst +12 -0
- package/ajv/lib/dot/_limitLength.jst +12 -0
- package/ajv/lib/dot/_limitProperties.jst +12 -0
- package/ajv/lib/dot/allOf.jst +32 -0
- package/ajv/lib/dot/anyOf.jst +46 -0
- package/ajv/lib/dot/coerce.def +51 -0
- package/ajv/lib/dot/comment.jst +9 -0
- package/ajv/lib/dot/const.jst +11 -0
- package/ajv/lib/dot/contains.jst +55 -0
- package/ajv/lib/dot/custom.jst +191 -0
- package/ajv/lib/dot/defaults.def +47 -0
- package/ajv/lib/dot/definitions.def +203 -0
- package/ajv/lib/dot/dependencies.jst +79 -0
- package/ajv/lib/dot/enum.jst +30 -0
- package/ajv/lib/dot/errors.def +194 -0
- package/ajv/lib/dot/format.jst +106 -0
- package/ajv/lib/dot/if.jst +73 -0
- package/ajv/lib/dot/items.jst +98 -0
- package/ajv/lib/dot/missing.def +39 -0
- package/ajv/lib/dot/multipleOf.jst +22 -0
- package/ajv/lib/dot/not.jst +43 -0
- package/ajv/lib/dot/oneOf.jst +54 -0
- package/ajv/lib/dot/pattern.jst +14 -0
- package/ajv/lib/dot/properties.jst +245 -0
- package/ajv/lib/dot/propertyNames.jst +52 -0
- package/ajv/lib/dot/ref.jst +85 -0
- package/ajv/lib/dot/required.jst +108 -0
- package/ajv/lib/dot/uniqueItems.jst +62 -0
- package/ajv/lib/dot/validate.jst +276 -0
- package/ajv/lib/dotjs/README.md +3 -0
- package/ajv/lib/dotjs/_limit.js +163 -0
- package/ajv/lib/dotjs/_limitItems.js +80 -0
- package/ajv/lib/dotjs/_limitLength.js +85 -0
- package/ajv/lib/dotjs/_limitProperties.js +80 -0
- package/ajv/lib/dotjs/allOf.js +42 -0
- package/ajv/lib/dotjs/anyOf.js +73 -0
- package/ajv/lib/dotjs/comment.js +14 -0
- package/ajv/lib/dotjs/const.js +56 -0
- package/ajv/lib/dotjs/contains.js +81 -0
- package/ajv/lib/dotjs/custom.js +228 -0
- package/ajv/lib/dotjs/dependencies.js +168 -0
- package/ajv/lib/dotjs/enum.js +66 -0
- package/ajv/lib/dotjs/format.js +150 -0
- package/ajv/lib/dotjs/if.js +103 -0
- package/ajv/lib/dotjs/index.js +33 -0
- package/ajv/lib/dotjs/items.js +140 -0
- package/ajv/lib/dotjs/multipleOf.js +80 -0
- package/ajv/lib/dotjs/not.js +84 -0
- package/ajv/lib/dotjs/oneOf.js +73 -0
- package/ajv/lib/dotjs/pattern.js +75 -0
- package/ajv/lib/dotjs/properties.js +335 -0
- package/ajv/lib/dotjs/propertyNames.js +81 -0
- package/ajv/lib/dotjs/ref.js +124 -0
- package/ajv/lib/dotjs/required.js +270 -0
- package/ajv/lib/dotjs/uniqueItems.js +86 -0
- package/ajv/lib/dotjs/validate.js +482 -0
- package/ajv/lib/keyword.js +146 -0
- package/ajv/lib/refs/data.json +17 -0
- package/ajv/lib/refs/json-schema-draft-04.json +149 -0
- package/ajv/lib/refs/json-schema-draft-06.json +154 -0
- package/ajv/lib/refs/json-schema-draft-07.json +168 -0
- package/ajv/lib/refs/json-schema-secure.json +94 -0
- package/ajv/package.json +81 -0
- package/ajv/scripts/.eslintrc.yml +3 -0
- package/ajv/scripts/bundle.js +61 -0
- package/ajv/scripts/compile-dots.js +73 -0
- package/ajv/scripts/info +10 -0
- package/ajv/scripts/prepare-tests +12 -0
- package/ajv/scripts/publish-built-version +32 -0
- package/ajv/scripts/travis-gh-pages +23 -0
- package/asn1/Jenkinsfile +65 -0
- package/asn1/LICENSE +19 -0
- package/asn1/README.md +50 -0
- package/asn1/lib/ber/errors.js +13 -0
- package/asn1/lib/ber/index.js +27 -0
- package/asn1/lib/ber/reader.js +262 -0
- package/asn1/lib/ber/types.js +36 -0
- package/asn1/lib/ber/writer.js +317 -0
- package/asn1/lib/index.js +20 -0
- package/asn1/package.json +26 -0
- package/assert-plus/AUTHORS +6 -0
- package/assert-plus/CHANGES.md +14 -0
- package/assert-plus/README.md +162 -0
- package/assert-plus/assert.js +211 -0
- package/assert-plus/package.json +21 -0
- package/asynckit/LICENSE +21 -0
- package/asynckit/README.md +233 -0
- package/asynckit/bench.js +76 -0
- package/asynckit/index.js +6 -0
- package/asynckit/lib/abort.js +29 -0
- package/asynckit/lib/async.js +34 -0
- package/asynckit/lib/defer.js +26 -0
- package/asynckit/lib/iterate.js +75 -0
- package/asynckit/lib/readable_asynckit.js +91 -0
- package/asynckit/lib/readable_parallel.js +25 -0
- package/asynckit/lib/readable_serial.js +25 -0
- package/asynckit/lib/readable_serial_ordered.js +29 -0
- package/asynckit/lib/state.js +37 -0
- package/asynckit/lib/streamify.js +141 -0
- package/asynckit/lib/terminator.js +29 -0
- package/asynckit/package.json +50 -0
- package/asynckit/parallel.js +43 -0
- package/asynckit/serial.js +17 -0
- package/asynckit/serialOrdered.js +75 -0
- package/asynckit/stream.js +21 -0
- package/aws-sign2/LICENSE +55 -0
- package/aws-sign2/README.md +4 -0
- package/aws-sign2/index.js +212 -0
- package/aws-sign2/package.json +17 -0
- package/aws4/.github/FUNDING.yml +3 -0
- package/aws4/.travis.yml +9 -0
- package/aws4/LICENSE +19 -0
- package/aws4/README.md +183 -0
- package/aws4/aws4.js +373 -0
- package/aws4/lru.js +96 -0
- package/aws4/package.json +16 -0
- package/axios/CHANGELOG.md +775 -0
- package/axios/LICENSE +19 -0
- package/axios/README.md +868 -0
- package/axios/SECURITY.md +5 -0
- package/axios/UPGRADE_GUIDE.md +162 -0
- package/axios/dist/axios.js +2193 -0
- package/axios/dist/axios.map +1 -0
- package/axios/dist/axios.min.js +3 -0
- package/axios/dist/axios.min.map +1 -0
- package/axios/index.d.ts +168 -0
- package/axios/index.js +1 -0
- package/axios/lib/adapters/README.md +37 -0
- package/axios/lib/adapters/http.js +331 -0
- package/axios/lib/adapters/xhr.js +189 -0
- package/axios/lib/axios.js +56 -0
- package/axios/lib/cancel/Cancel.js +19 -0
- package/axios/lib/cancel/CancelToken.js +57 -0
- package/axios/lib/cancel/isCancel.js +5 -0
- package/axios/lib/core/Axios.js +148 -0
- package/axios/lib/core/InterceptorManager.js +54 -0
- package/axios/lib/core/README.md +8 -0
- package/axios/lib/core/buildFullPath.js +20 -0
- package/axios/lib/core/createError.js +18 -0
- package/axios/lib/core/dispatchRequest.js +82 -0
- package/axios/lib/core/enhanceError.js +42 -0
- package/axios/lib/core/mergeConfig.js +87 -0
- package/axios/lib/core/settle.js +25 -0
- package/axios/lib/core/transformData.js +22 -0
- package/axios/lib/defaults.js +134 -0
- package/axios/lib/helpers/README.md +7 -0
- package/axios/lib/helpers/bind.js +11 -0
- package/axios/lib/helpers/buildURL.js +70 -0
- package/axios/lib/helpers/combineURLs.js +14 -0
- package/axios/lib/helpers/cookies.js +53 -0
- package/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/axios/lib/helpers/isAxiosError.js +11 -0
- package/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/axios/lib/helpers/parseHeaders.js +53 -0
- package/axios/lib/helpers/spread.js +27 -0
- package/axios/lib/helpers/validator.js +105 -0
- package/axios/lib/utils.js +349 -0
- package/axios/package.json +52 -0
- package/bcrypt-pbkdf/CONTRIBUTING.md +13 -0
- package/bcrypt-pbkdf/LICENSE +66 -0
- package/bcrypt-pbkdf/README.md +45 -0
- package/bcrypt-pbkdf/index.js +556 -0
- package/bcrypt-pbkdf/package.json +15 -0
- package/caseless/LICENSE +28 -0
- package/caseless/README.md +45 -0
- package/caseless/index.js +67 -0
- package/caseless/package.json +27 -0
- package/caseless/test.js +67 -0
- package/combined-stream/License +19 -0
- package/combined-stream/Readme.md +138 -0
- package/combined-stream/lib/combined_stream.js +208 -0
- package/combined-stream/package.json +24 -0
- package/combined-stream/yarn.lock +17 -0
- package/core-util-is/LICENSE +19 -0
- package/core-util-is/README.md +3 -0
- package/core-util-is/float.patch +604 -0
- package/core-util-is/lib/util.js +107 -0
- package/core-util-is/package.json +32 -0
- package/core-util-is/test.js +68 -0
- package/dashdash/CHANGES.md +364 -0
- package/dashdash/LICENSE.txt +24 -0
- package/dashdash/README.md +574 -0
- package/dashdash/etc/dashdash.bash_completion.in +389 -0
- package/dashdash/lib/dashdash.js +1055 -0
- package/dashdash/package.json +26 -0
- package/delayed-stream/License +19 -0
- package/delayed-stream/Makefile +7 -0
- package/delayed-stream/Readme.md +141 -0
- package/delayed-stream/lib/delayed_stream.js +107 -0
- package/delayed-stream/package.json +26 -0
- package/ecc-jsbn/LICENSE +21 -0
- package/ecc-jsbn/README.md +8 -0
- package/ecc-jsbn/index.js +58 -0
- package/ecc-jsbn/lib/LICENSE-jsbn +40 -0
- package/ecc-jsbn/lib/ec.js +561 -0
- package/ecc-jsbn/lib/sec.js +170 -0
- package/ecc-jsbn/package.json +39 -0
- package/ecc-jsbn/test.js +14 -0
- package/extend/.editorconfig +20 -0
- package/extend/.eslintrc +17 -0
- package/extend/.jscs.json +175 -0
- package/extend/.travis.yml +230 -0
- package/extend/CHANGELOG.md +83 -0
- package/extend/LICENSE +23 -0
- package/extend/README.md +81 -0
- package/extend/component.json +32 -0
- package/extend/index.js +117 -0
- package/extend/package.json +38 -0
- package/extsprintf/.gitmodules +0 -0
- package/extsprintf/LICENSE +19 -0
- package/extsprintf/Makefile +24 -0
- package/extsprintf/Makefile.targ +285 -0
- package/extsprintf/README.md +46 -0
- package/extsprintf/jsl.node.conf +137 -0
- package/extsprintf/lib/extsprintf.js +183 -0
- package/extsprintf/package.json +14 -0
- package/fast-deep-equal/LICENSE +21 -0
- package/fast-deep-equal/README.md +96 -0
- package/fast-deep-equal/es6/index.d.ts +2 -0
- package/fast-deep-equal/es6/index.js +72 -0
- package/fast-deep-equal/es6/react.d.ts +2 -0
- package/fast-deep-equal/es6/react.js +79 -0
- package/fast-deep-equal/index.d.ts +4 -0
- package/fast-deep-equal/index.js +46 -0
- package/fast-deep-equal/package.json +52 -0
- package/fast-deep-equal/react.d.ts +2 -0
- package/fast-deep-equal/react.js +53 -0
- package/fast-json-stable-stringify/.eslintrc.yml +26 -0
- package/fast-json-stable-stringify/.github/FUNDING.yml +1 -0
- package/fast-json-stable-stringify/.travis.yml +8 -0
- package/fast-json-stable-stringify/LICENSE +21 -0
- package/fast-json-stable-stringify/README.md +131 -0
- package/fast-json-stable-stringify/benchmark/index.js +31 -0
- package/fast-json-stable-stringify/benchmark/test.json +137 -0
- package/fast-json-stable-stringify/example/key_cmp.js +7 -0
- package/fast-json-stable-stringify/example/nested.js +3 -0
- package/fast-json-stable-stringify/example/str.js +3 -0
- package/fast-json-stable-stringify/example/value_cmp.js +7 -0
- package/fast-json-stable-stringify/index.d.ts +4 -0
- package/fast-json-stable-stringify/index.js +59 -0
- package/fast-json-stable-stringify/package.json +44 -0
- package/fast-json-stable-stringify/test/cmp.js +13 -0
- package/fast-json-stable-stringify/test/nested.js +44 -0
- package/fast-json-stable-stringify/test/str.js +46 -0
- package/fast-json-stable-stringify/test/to-json.js +22 -0
- package/follow-redirects/LICENSE +18 -0
- package/follow-redirects/README.md +155 -0
- package/follow-redirects/debug.js +15 -0
- package/follow-redirects/http.js +1 -0
- package/follow-redirects/https.js +1 -0
- package/follow-redirects/index.js +598 -0
- package/follow-redirects/package.json +54 -0
- package/forever-agent/LICENSE +55 -0
- package/forever-agent/README.md +4 -0
- package/forever-agent/index.js +138 -0
- package/forever-agent/package.json +17 -0
- package/form-data/License +19 -0
- package/form-data/README.md +234 -0
- package/form-data/README.md.bak +234 -0
- package/form-data/lib/browser.js +2 -0
- package/form-data/lib/form_data.js +457 -0
- package/form-data/lib/populate.js +10 -0
- package/form-data/package.json +46 -0
- package/form-data/yarn.lock +2662 -0
- package/getpass/.travis.yml +9 -0
- package/getpass/LICENSE +18 -0
- package/getpass/README.md +32 -0
- package/getpass/lib/index.js +123 -0
- package/getpass/package.json +18 -0
- package/har-schema/LICENSE +13 -0
- package/har-schema/README.md +49 -0
- package/har-schema/lib/afterRequest.json +30 -0
- package/har-schema/lib/beforeRequest.json +30 -0
- package/har-schema/lib/browser.json +20 -0
- package/har-schema/lib/cache.json +21 -0
- package/har-schema/lib/content.json +29 -0
- package/har-schema/lib/cookie.json +36 -0
- package/har-schema/lib/creator.json +20 -0
- package/har-schema/lib/entry.json +53 -0
- package/har-schema/lib/har.json +13 -0
- package/har-schema/lib/header.json +20 -0
- package/har-schema/lib/index.js +22 -0
- package/har-schema/lib/log.json +36 -0
- package/har-schema/lib/page.json +32 -0
- package/har-schema/lib/pageTimings.json +18 -0
- package/har-schema/lib/postData.json +43 -0
- package/har-schema/lib/query.json +20 -0
- package/har-schema/lib/request.json +57 -0
- package/har-schema/lib/response.json +54 -0
- package/har-schema/lib/timings.json +42 -0
- package/har-schema/package.json +48 -0
- package/har-validator/LICENSE +9 -0
- package/har-validator/README.md +43 -0
- package/har-validator/lib/async.js +105 -0
- package/har-validator/lib/error.js +17 -0
- package/har-validator/lib/promise.js +102 -0
- package/har-validator/package.json +42 -0
- package/http-signature/.dir-locals.el +6 -0
- package/http-signature/CHANGES.md +46 -0
- package/http-signature/LICENSE +18 -0
- package/http-signature/README.md +79 -0
- package/http-signature/http_signing.md +363 -0
- package/http-signature/lib/index.js +29 -0
- package/http-signature/lib/parser.js +315 -0
- package/http-signature/lib/signer.js +401 -0
- package/http-signature/lib/utils.js +112 -0
- package/http-signature/lib/verify.js +88 -0
- package/http-signature/package.json +36 -0
- package/is-typedarray/LICENSE.md +18 -0
- package/is-typedarray/README.md +16 -0
- package/is-typedarray/index.js +41 -0
- package/is-typedarray/package.json +30 -0
- package/is-typedarray/test.js +34 -0
- package/isstream/.jshintrc +59 -0
- package/isstream/.travis.yml +12 -0
- package/isstream/LICENSE.md +11 -0
- package/isstream/README.md +66 -0
- package/isstream/isstream.js +27 -0
- package/isstream/package.json +29 -0
- package/isstream/test.js +168 -0
- package/jsbn/LICENSE +40 -0
- package/jsbn/README.md +175 -0
- package/jsbn/example.html +12 -0
- package/jsbn/example.js +3 -0
- package/jsbn/index.js +1357 -0
- package/jsbn/package.json +21 -0
- package/json-schema/LICENSE +195 -0
- package/json-schema/README.md +3 -0
- package/json-schema/lib/links.js +65 -0
- package/json-schema/lib/validate.js +271 -0
- package/json-schema/package.json +24 -0
- package/json-schema-traverse/.eslintrc.yml +27 -0
- package/json-schema-traverse/.travis.yml +8 -0
- package/json-schema-traverse/LICENSE +21 -0
- package/json-schema-traverse/README.md +83 -0
- package/json-schema-traverse/index.js +89 -0
- package/json-schema-traverse/package.json +39 -0
- package/json-schema-traverse/spec/.eslintrc.yml +6 -0
- package/json-schema-traverse/spec/fixtures/schema.js +125 -0
- package/json-schema-traverse/spec/index.spec.js +171 -0
- package/json-stringify-safe/CHANGELOG.md +14 -0
- package/json-stringify-safe/LICENSE +15 -0
- package/json-stringify-safe/Makefile +35 -0
- package/json-stringify-safe/README.md +52 -0
- package/json-stringify-safe/package.json +29 -0
- package/json-stringify-safe/stringify.js +27 -0
- package/json-stringify-safe/test/mocha.opts +2 -0
- package/json-stringify-safe/test/stringify_test.js +246 -0
- package/jsprim/CHANGES.md +53 -0
- package/jsprim/CONTRIBUTING.md +19 -0
- package/jsprim/LICENSE +19 -0
- package/jsprim/README.md +287 -0
- package/jsprim/lib/jsprim.js +735 -0
- package/jsprim/package.json +17 -0
- package/m3u8stream/LICENSE +21 -0
- package/m3u8stream/README.md +81 -0
- package/m3u8stream/dist/dash-mpd-parser.d.ts +11 -0
- package/m3u8stream/dist/dash-mpd-parser.js +183 -0
- package/m3u8stream/dist/dash-mpd-parser.js.map +1 -0
- package/m3u8stream/dist/index.d.ts +31 -0
- package/m3u8stream/dist/index.js +180 -0
- package/m3u8stream/dist/index.js.map +1 -0
- package/m3u8stream/dist/m3u8-parser.d.ts +18 -0
- package/m3u8stream/dist/m3u8-parser.js +111 -0
- package/m3u8stream/dist/m3u8-parser.js.map +1 -0
- package/m3u8stream/dist/parse-time.d.ts +16 -0
- package/m3u8stream/dist/parse-time.js +59 -0
- package/m3u8stream/dist/parse-time.js.map +1 -0
- package/m3u8stream/dist/parser.d.ts +19 -0
- package/m3u8stream/dist/parser.js +3 -0
- package/m3u8stream/dist/parser.js.map +1 -0
- package/m3u8stream/dist/queue.d.ts +39 -0
- package/m3u8stream/dist/queue.js +58 -0
- package/m3u8stream/dist/queue.js.map +1 -0
- package/m3u8stream/node_modules/sax/LICENSE +41 -0
- package/m3u8stream/node_modules/sax/README.md +225 -0
- package/m3u8stream/node_modules/sax/lib/sax.js +1565 -0
- package/m3u8stream/node_modules/sax/package.json +25 -0
- package/m3u8stream/package.json +41 -0
- package/mime-db/HISTORY.md +507 -0
- package/mime-db/LICENSE +23 -0
- package/mime-db/README.md +100 -0
- package/mime-db/db.json +8519 -0
- package/mime-db/index.js +12 -0
- package/mime-db/package.json +44 -0
- package/mime-types/HISTORY.md +397 -0
- package/mime-types/LICENSE +23 -0
- package/mime-types/README.md +113 -0
- package/mime-types/index.js +188 -0
- package/mime-types/package.json +36 -0
- package/miniget/LICENSE +21 -0
- package/miniget/README.md +111 -0
- package/miniget/dist/index.d.ts +65 -0
- package/miniget/dist/index.js +281 -0
- package/miniget/dist/index.js.map +1 -0
- package/miniget/package.json +36 -0
- package/oauth-sign/LICENSE +55 -0
- package/oauth-sign/README.md +11 -0
- package/oauth-sign/index.js +146 -0
- package/oauth-sign/package.json +23 -0
- package/package.json +11 -0
- package/performance-now/.tm_properties +7 -0
- package/performance-now/.travis.yml +6 -0
- package/performance-now/README.md +30 -0
- package/performance-now/lib/performance-now.js +36 -0
- package/performance-now/lib/performance-now.js.map +10 -0
- package/performance-now/license.txt +7 -0
- package/performance-now/package.json +29 -0
- package/performance-now/src/index.d.ts +8 -0
- package/performance-now/src/performance-now.coffee +17 -0
- package/performance-now/test/mocha.opts +3 -0
- package/performance-now/test/performance-now.coffee +43 -0
- package/performance-now/test/scripts/delayed-call.coffee +11 -0
- package/performance-now/test/scripts/delayed-require.coffee +12 -0
- package/performance-now/test/scripts/difference.coffee +6 -0
- package/performance-now/test/scripts/initial-value.coffee +10 -0
- package/performance-now/test/scripts.coffee +27 -0
- package/psl/.env +0 -0
- package/psl/LICENSE +9 -0
- package/psl/README.md +211 -0
- package/psl/browserstack-logo.svg +90 -0
- package/psl/data/rules.json +9376 -0
- package/psl/dist/psl.js +10187 -0
- package/psl/dist/psl.min.js +1 -0
- package/psl/index.js +269 -0
- package/psl/package.json +30 -0
- package/punycode/LICENSE-MIT.txt +20 -0
- package/punycode/README.md +122 -0
- package/punycode/package.json +56 -0
- package/punycode/punycode.es6.js +441 -0
- package/punycode/punycode.js +440 -0
- package/qs/.editorconfig +43 -0
- package/qs/.eslintrc +37 -0
- package/qs/.github/FUNDING.yml +12 -0
- package/qs/.nycrc +13 -0
- package/qs/CHANGELOG.md +250 -0
- package/qs/LICENSE.md +29 -0
- package/qs/README.md +510 -0
- package/qs/bower.json +21 -0
- package/qs/component.json +15 -0
- package/qs/dist/qs.js +648 -0
- package/qs/lib/formats.js +18 -0
- package/qs/lib/index.js +11 -0
- package/qs/lib/parse.js +175 -0
- package/qs/lib/stringify.js +217 -0
- package/qs/lib/utils.js +215 -0
- package/qs/package.json +41 -0
- package/qs/test/index.js +7 -0
- package/qs/test/parse.js +649 -0
- package/qs/test/stringify.js +642 -0
- package/qs/test/utils.js +65 -0
- package/request/CHANGELOG.md +717 -0
- package/request/LICENSE +55 -0
- package/request/README.md +1133 -0
- package/request/index.js +155 -0
- package/request/lib/auth.js +167 -0
- package/request/lib/cookies.js +38 -0
- package/request/lib/getProxyFromURI.js +79 -0
- package/request/lib/har.js +205 -0
- package/request/lib/hawk.js +89 -0
- package/request/lib/helpers.js +66 -0
- package/request/lib/multipart.js +112 -0
- package/request/lib/oauth.js +148 -0
- package/request/lib/querystring.js +50 -0
- package/request/lib/redirect.js +154 -0
- package/request/lib/tunnel.js +175 -0
- package/request/package.json +48 -0
- package/request/request.js +1553 -0
- package/safe-buffer/LICENSE +21 -0
- package/safe-buffer/README.md +584 -0
- package/safe-buffer/index.d.ts +187 -0
- package/safe-buffer/index.js +65 -0
- package/safe-buffer/package.json +50 -0
- package/safer-buffer/LICENSE +21 -0
- package/safer-buffer/Porting-Buffer.md +268 -0
- package/safer-buffer/Readme.md +156 -0
- package/safer-buffer/dangerous.js +58 -0
- package/safer-buffer/package.json +33 -0
- package/safer-buffer/safer.js +77 -0
- package/safer-buffer/tests.js +406 -0
- package/sax/AUTHORS +10 -0
- package/sax/LICENSE +32 -0
- package/sax/LICENSE-W3C.html +188 -0
- package/sax/README.md +216 -0
- package/sax/component.json +12 -0
- package/sax/examples/big-not-pretty.xml +8002 -0
- package/sax/examples/example.js +29 -0
- package/sax/examples/get-products.js +58 -0
- package/sax/examples/hello-world.js +4 -0
- package/sax/examples/not-pretty.xml +8 -0
- package/sax/examples/pretty-print.js +74 -0
- package/sax/examples/shopping.xml +2 -0
- package/sax/examples/strict.dtd +870 -0
- package/sax/examples/test.html +15 -0
- package/sax/examples/test.xml +1254 -0
- package/sax/lib/sax.js +1355 -0
- package/sax/package.json +12 -0
- package/sax/test/attribute-name.js +33 -0
- package/sax/test/attribute-no-space.js +75 -0
- package/sax/test/buffer-overrun.js +26 -0
- package/sax/test/case.js +50 -0
- package/sax/test/cdata-chunked.js +11 -0
- package/sax/test/cdata-end-split.js +15 -0
- package/sax/test/cdata-fake-end.js +28 -0
- package/sax/test/cdata-multiple.js +15 -0
- package/sax/test/cdata.js +10 -0
- package/sax/test/cyrillic.js +8 -0
- package/sax/test/duplicate-attribute.js +13 -0
- package/sax/test/end_empty_stream.js +5 -0
- package/sax/test/entities.js +10 -0
- package/sax/test/entity-mega.js +16 -0
- package/sax/test/flush.js +13 -0
- package/sax/test/index.js +86 -0
- package/sax/test/issue-23.js +43 -0
- package/sax/test/issue-30.js +24 -0
- package/sax/test/issue-35.js +15 -0
- package/sax/test/issue-47.js +12 -0
- package/sax/test/issue-49.js +31 -0
- package/sax/test/issue-84.js +13 -0
- package/sax/test/parser-position.js +28 -0
- package/sax/test/script-close-better.js +12 -0
- package/sax/test/script.js +12 -0
- package/sax/test/self-closing-child-strict.js +44 -0
- package/sax/test/self-closing-child.js +44 -0
- package/sax/test/self-closing-tag.js +25 -0
- package/sax/test/stray-ending.js +17 -0
- package/sax/test/trailing-attribute-no-value.js +10 -0
- package/sax/test/trailing-non-whitespace.js +18 -0
- package/sax/test/unclosed-root.js +11 -0
- package/sax/test/unquoted.js +18 -0
- package/sax/test/utf8-split.js +32 -0
- package/sax/test/xmlns-as-tag-name.js +15 -0
- package/sax/test/xmlns-issue-41.js +68 -0
- package/sax/test/xmlns-rebinding.js +63 -0
- package/sax/test/xmlns-strict.js +74 -0
- package/sax/test/xmlns-unbound-element.js +33 -0
- package/sax/test/xmlns-unbound.js +15 -0
- package/sax/test/xmlns-xml-default-ns.js +31 -0
- package/sax/test/xmlns-xml-default-prefix-attribute.js +36 -0
- package/sax/test/xmlns-xml-default-prefix.js +21 -0
- package/sax/test/xmlns-xml-default-redefine.js +41 -0
- package/simple-csv-reader/.editorconfig +8 -0
- package/simple-csv-reader/LICENSE +21 -0
- package/simple-csv-reader/README.md +32 -0
- package/simple-csv-reader/dist/simple-csv-reader.min.js +2 -0
- package/simple-csv-reader/dist/simple-csv-reader.min.js.map +1 -0
- package/simple-csv-reader/gulpfile.js +26 -0
- package/simple-csv-reader/index.js +131 -0
- package/simple-csv-reader/package.json +30 -0
- package/sshpk/.travis.yml +11 -0
- package/sshpk/Jenkinsfile +86 -0
- package/sshpk/LICENSE +18 -0
- package/sshpk/README.md +804 -0
- package/sshpk/bin/sshpk-conv +243 -0
- package/sshpk/bin/sshpk-sign +191 -0
- package/sshpk/bin/sshpk-verify +167 -0
- package/sshpk/lib/algs.js +168 -0
- package/sshpk/lib/certificate.js +410 -0
- package/sshpk/lib/dhe.js +397 -0
- package/sshpk/lib/ed-compat.js +92 -0
- package/sshpk/lib/errors.js +84 -0
- package/sshpk/lib/fingerprint.js +220 -0
- package/sshpk/lib/formats/auto.js +124 -0
- package/sshpk/lib/formats/dnssec.js +287 -0
- package/sshpk/lib/formats/openssh-cert.js +352 -0
- package/sshpk/lib/formats/pem.js +290 -0
- package/sshpk/lib/formats/pkcs1.js +373 -0
- package/sshpk/lib/formats/pkcs8.js +631 -0
- package/sshpk/lib/formats/putty.js +194 -0
- package/sshpk/lib/formats/rfc4253.js +166 -0
- package/sshpk/lib/formats/ssh-private.js +262 -0
- package/sshpk/lib/formats/ssh.js +115 -0
- package/sshpk/lib/formats/x509-pem.js +88 -0
- package/sshpk/lib/formats/x509.js +752 -0
- package/sshpk/lib/identity.js +373 -0
- package/sshpk/lib/index.js +40 -0
- package/sshpk/lib/key.js +294 -0
- package/sshpk/lib/private-key.js +247 -0
- package/sshpk/lib/signature.js +314 -0
- package/sshpk/lib/ssh-buffer.js +149 -0
- package/sshpk/lib/utils.js +404 -0
- package/sshpk/man/man1/sshpk-conv.1 +135 -0
- package/sshpk/man/man1/sshpk-sign.1 +81 -0
- package/sshpk/man/man1/sshpk-verify.1 +68 -0
- package/sshpk/package.json +49 -0
- package/tough-cookie/LICENSE +12 -0
- package/tough-cookie/README.md +527 -0
- package/tough-cookie/lib/cookie.js +1482 -0
- package/tough-cookie/lib/memstore.js +181 -0
- package/tough-cookie/lib/pathMatch.js +61 -0
- package/tough-cookie/lib/permuteDomain.js +56 -0
- package/tough-cookie/lib/pubsuffix-psl.js +38 -0
- package/tough-cookie/lib/store.js +75 -0
- package/tough-cookie/lib/version.js +2 -0
- package/tough-cookie/package.json +73 -0
- package/tunnel-agent/LICENSE +55 -0
- package/tunnel-agent/README.md +4 -0
- package/tunnel-agent/index.js +244 -0
- package/tunnel-agent/package.json +22 -0
- package/tweetnacl/AUTHORS.md +28 -0
- package/tweetnacl/CHANGELOG.md +221 -0
- package/tweetnacl/LICENSE +24 -0
- package/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
- package/tweetnacl/README.md +459 -0
- package/tweetnacl/nacl-fast.js +2388 -0
- package/tweetnacl/nacl-fast.min.js +2 -0
- package/tweetnacl/nacl.d.ts +98 -0
- package/tweetnacl/nacl.js +1175 -0
- package/tweetnacl/nacl.min.js +1 -0
- package/tweetnacl/package.json +51 -0
- package/uri-js/LICENSE +11 -0
- package/uri-js/README.md +203 -0
- package/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/uri-js/dist/es5/uri.all.js +1443 -0
- package/uri-js/dist/es5/uri.all.js.map +1 -0
- package/uri-js/dist/es5/uri.all.min.d.ts +59 -0
- package/uri-js/dist/es5/uri.all.min.js +3 -0
- package/uri-js/dist/es5/uri.all.min.js.map +1 -0
- package/uri-js/dist/esnext/index.d.ts +1 -0
- package/uri-js/dist/esnext/index.js +17 -0
- package/uri-js/dist/esnext/index.js.map +1 -0
- package/uri-js/dist/esnext/regexps-iri.d.ts +3 -0
- package/uri-js/dist/esnext/regexps-iri.js +3 -0
- package/uri-js/dist/esnext/regexps-iri.js.map +1 -0
- package/uri-js/dist/esnext/regexps-uri.d.ts +4 -0
- package/uri-js/dist/esnext/regexps-uri.js +42 -0
- package/uri-js/dist/esnext/regexps-uri.js.map +1 -0
- package/uri-js/dist/esnext/schemes/http.d.ts +3 -0
- package/uri-js/dist/esnext/schemes/http.js +28 -0
- package/uri-js/dist/esnext/schemes/http.js.map +1 -0
- package/uri-js/dist/esnext/schemes/https.d.ts +3 -0
- package/uri-js/dist/esnext/schemes/https.js +9 -0
- package/uri-js/dist/esnext/schemes/https.js.map +1 -0
- package/uri-js/dist/esnext/schemes/mailto.d.ts +12 -0
- package/uri-js/dist/esnext/schemes/mailto.js +148 -0
- package/uri-js/dist/esnext/schemes/mailto.js.map +1 -0
- package/uri-js/dist/esnext/schemes/urn-uuid.d.ts +7 -0
- package/uri-js/dist/esnext/schemes/urn-uuid.js +23 -0
- package/uri-js/dist/esnext/schemes/urn-uuid.js.map +1 -0
- package/uri-js/dist/esnext/schemes/urn.d.ts +10 -0
- package/uri-js/dist/esnext/schemes/urn.js +49 -0
- package/uri-js/dist/esnext/schemes/urn.js.map +1 -0
- package/uri-js/dist/esnext/schemes/ws.d.ts +7 -0
- package/uri-js/dist/esnext/schemes/ws.js +41 -0
- package/uri-js/dist/esnext/schemes/ws.js.map +1 -0
- package/uri-js/dist/esnext/schemes/wss.d.ts +3 -0
- package/uri-js/dist/esnext/schemes/wss.js +9 -0
- package/uri-js/dist/esnext/schemes/wss.js.map +1 -0
- package/uri-js/dist/esnext/uri.d.ts +59 -0
- package/uri-js/dist/esnext/uri.js +480 -0
- package/uri-js/dist/esnext/uri.js.map +1 -0
- package/uri-js/dist/esnext/util.d.ts +6 -0
- package/uri-js/dist/esnext/util.js +36 -0
- package/uri-js/dist/esnext/util.js.map +1 -0
- package/uri-js/package.json +67 -0
- package/uri-js/yarn.lock +2558 -0
- package/uuid/AUTHORS +5 -0
- package/uuid/CHANGELOG.md +119 -0
- package/uuid/LICENSE.md +21 -0
- package/uuid/README.md +276 -0
- package/uuid/bin/uuid +65 -0
- package/uuid/index.js +8 -0
- package/uuid/lib/bytesToUuid.js +26 -0
- package/uuid/lib/md5-browser.js +216 -0
- package/uuid/lib/md5.js +25 -0
- package/uuid/lib/rng-browser.js +34 -0
- package/uuid/lib/rng.js +8 -0
- package/uuid/lib/sha1-browser.js +89 -0
- package/uuid/lib/sha1.js +25 -0
- package/uuid/lib/v35.js +57 -0
- package/uuid/package.json +43 -0
- package/uuid/v1.js +109 -0
- package/uuid/v3.js +4 -0
- package/uuid/v4.js +29 -0
- package/uuid/v5.js +3 -0
- package/verror/CHANGES.md +28 -0
- package/verror/CONTRIBUTING.md +19 -0
- package/verror/LICENSE +19 -0
- package/verror/README.md +528 -0
- package/verror/lib/verror.js +451 -0
- package/verror/package.json +20 -0
- package/xml2js/.travis.yml +5 -0
- package/xml2js/83.coffee +6 -0
- package/xml2js/LICENSE +19 -0
- package/xml2js/README.md +248 -0
- package/xml2js/canon.xml +482 -0
- package/xml2js/lib/xml2js.js +299 -0
- package/xml2js/package.json +45 -0
- package/xml2js/text.coffee +11 -0
- package/xml2js/text.xml +485 -0
- package/youtube-downloader-by-ahmad/LICENSE +21 -0
- package/youtube-downloader-by-ahmad/README.md +238 -0
- package/youtube-downloader-by-ahmad/lib/cache.js +54 -0
- package/youtube-downloader-by-ahmad/lib/format-utils.js +250 -0
- package/youtube-downloader-by-ahmad/lib/formats.js +524 -0
- package/youtube-downloader-by-ahmad/lib/index.js +214 -0
- package/youtube-downloader-by-ahmad/lib/info-extras.js +365 -0
- package/youtube-downloader-by-ahmad/lib/info.js +495 -0
- package/youtube-downloader-by-ahmad/lib/sig.js +122 -0
- package/youtube-downloader-by-ahmad/lib/url-utils.js +91 -0
- package/youtube-downloader-by-ahmad/lib/utils.js +286 -0
- package/youtube-downloader-by-ahmad/node_modules/sax/LICENSE +41 -0
- package/youtube-downloader-by-ahmad/node_modules/sax/README.md +225 -0
- package/youtube-downloader-by-ahmad/node_modules/sax/lib/sax.js +1565 -0
- package/youtube-downloader-by-ahmad/node_modules/sax/package.json +25 -0
- package/youtube-downloader-by-ahmad/package.json +61 -0
- package/youtube-downloader-by-ahmad/typings/index.d.ts +426 -0
- package/youtube-search/.travis.yml +5 -0
- package/youtube-search/README.md +61 -0
- package/youtube-search/index.d.ts +77 -0
- package/youtube-search/index.js +111 -0
- package/youtube-search/package.json +26 -0
- package/youtube-search/tests/test-search.js +32 -0
- package/ytdl-getinfo/.travis.yml +3 -0
- package/ytdl-getinfo/README.md +77 -0
- package/ytdl-getinfo/index.js +105 -0
- package/ytdl-getinfo/package.json +30 -0
- package/ytdl-getinfo/playlist.js +50 -0
- package/ytdl-getinfo/test/test.js +68 -0
- package/ytdl-getinfo/updater.js +42 -0
- package/ytdl-getinfo/yarn.lock +533 -0
- package/ytdl-getinfo/ytdl/.gitkeep +0 -0
- package/ytdl-getinfo/ytdl/youtube-dl.exe +0 -0
package/axios/README.md
ADDED
@@ -0,0 +1,868 @@
|
|
1
|
+
# axios
|
2
|
+
|
3
|
+
[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
|
4
|
+
[![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios)
|
5
|
+
![Build status](https://github.com/axios/axios/actions/workflows/ci.yml/badge.svg)
|
6
|
+
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/axios/axios)
|
7
|
+
[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
|
8
|
+
[![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)
|
9
|
+
[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios)
|
10
|
+
[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios)
|
11
|
+
[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
|
12
|
+
|
13
|
+
Promise based HTTP client for the browser and node.js
|
14
|
+
|
15
|
+
> New axios docs website: [click here](https://axios-http.com/)
|
16
|
+
|
17
|
+
## Table of Contents
|
18
|
+
|
19
|
+
- [Features](#features)
|
20
|
+
- [Browser Support](#browser-support)
|
21
|
+
- [Installing](#installing)
|
22
|
+
- [Example](#example)
|
23
|
+
- [Axios API](#axios-api)
|
24
|
+
- [Request method aliases](#request-method-aliases)
|
25
|
+
- [Concurrency (Deprecated)](#concurrency-deprecated)
|
26
|
+
- [Creating an instance](#creating-an-instance)
|
27
|
+
- [Instance methods](#instance-methods)
|
28
|
+
- [Request Config](#request-config)
|
29
|
+
- [Response Schema](#response-schema)
|
30
|
+
- [Config Defaults](#config-defaults)
|
31
|
+
- [Global axios defaults](#global-axios-defaults)
|
32
|
+
- [Custom instance defaults](#custom-instance-defaults)
|
33
|
+
- [Config order of precedence](#config-order-of-precedence)
|
34
|
+
- [Interceptors](#interceptors)
|
35
|
+
- [Handling Errors](#handling-errors)
|
36
|
+
- [Cancellation](#cancellation)
|
37
|
+
- [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format)
|
38
|
+
- [Browser](#browser)
|
39
|
+
- [Node.js](#nodejs)
|
40
|
+
- [Query string](#query-string)
|
41
|
+
- [Form data](#form-data)
|
42
|
+
- [Semver](#semver)
|
43
|
+
- [Promises](#promises)
|
44
|
+
- [TypeScript](#typescript)
|
45
|
+
- [Resources](#resources)
|
46
|
+
- [Credits](#credits)
|
47
|
+
- [License](#license)
|
48
|
+
|
49
|
+
## Features
|
50
|
+
|
51
|
+
- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser
|
52
|
+
- Make [http](http://nodejs.org/api/http.html) requests from node.js
|
53
|
+
- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API
|
54
|
+
- Intercept request and response
|
55
|
+
- Transform request and response data
|
56
|
+
- Cancel requests
|
57
|
+
- Automatic transforms for JSON data
|
58
|
+
- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)
|
59
|
+
|
60
|
+
## Browser Support
|
61
|
+
|
62
|
+
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |
|
63
|
+
--- | --- | --- | --- | --- | --- |
|
64
|
+
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
|
65
|
+
|
66
|
+
[![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios)
|
67
|
+
|
68
|
+
## Installing
|
69
|
+
|
70
|
+
Using npm:
|
71
|
+
|
72
|
+
```bash
|
73
|
+
$ npm install axios
|
74
|
+
```
|
75
|
+
|
76
|
+
Using bower:
|
77
|
+
|
78
|
+
```bash
|
79
|
+
$ bower install axios
|
80
|
+
```
|
81
|
+
|
82
|
+
Using yarn:
|
83
|
+
|
84
|
+
```bash
|
85
|
+
$ yarn add axios
|
86
|
+
```
|
87
|
+
|
88
|
+
Using jsDelivr CDN:
|
89
|
+
|
90
|
+
```html
|
91
|
+
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
92
|
+
```
|
93
|
+
|
94
|
+
Using unpkg CDN:
|
95
|
+
|
96
|
+
```html
|
97
|
+
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
98
|
+
```
|
99
|
+
|
100
|
+
## Example
|
101
|
+
|
102
|
+
### note: CommonJS usage
|
103
|
+
In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach:
|
104
|
+
|
105
|
+
```js
|
106
|
+
const axios = require('axios').default;
|
107
|
+
|
108
|
+
// axios.<method> will now provide autocomplete and parameter typings
|
109
|
+
```
|
110
|
+
|
111
|
+
Performing a `GET` request
|
112
|
+
|
113
|
+
```js
|
114
|
+
const axios = require('axios');
|
115
|
+
|
116
|
+
// Make a request for a user with a given ID
|
117
|
+
axios.get('/user?ID=12345')
|
118
|
+
.then(function (response) {
|
119
|
+
// handle success
|
120
|
+
console.log(response);
|
121
|
+
})
|
122
|
+
.catch(function (error) {
|
123
|
+
// handle error
|
124
|
+
console.log(error);
|
125
|
+
})
|
126
|
+
.then(function () {
|
127
|
+
// always executed
|
128
|
+
});
|
129
|
+
|
130
|
+
// Optionally the request above could also be done as
|
131
|
+
axios.get('/user', {
|
132
|
+
params: {
|
133
|
+
ID: 12345
|
134
|
+
}
|
135
|
+
})
|
136
|
+
.then(function (response) {
|
137
|
+
console.log(response);
|
138
|
+
})
|
139
|
+
.catch(function (error) {
|
140
|
+
console.log(error);
|
141
|
+
})
|
142
|
+
.then(function () {
|
143
|
+
// always executed
|
144
|
+
});
|
145
|
+
|
146
|
+
// Want to use async/await? Add the `async` keyword to your outer function/method.
|
147
|
+
async function getUser() {
|
148
|
+
try {
|
149
|
+
const response = await axios.get('/user?ID=12345');
|
150
|
+
console.log(response);
|
151
|
+
} catch (error) {
|
152
|
+
console.error(error);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
```
|
156
|
+
|
157
|
+
> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet
|
158
|
+
> Explorer and older browsers, so use with caution.
|
159
|
+
|
160
|
+
Performing a `POST` request
|
161
|
+
|
162
|
+
```js
|
163
|
+
axios.post('/user', {
|
164
|
+
firstName: 'Fred',
|
165
|
+
lastName: 'Flintstone'
|
166
|
+
})
|
167
|
+
.then(function (response) {
|
168
|
+
console.log(response);
|
169
|
+
})
|
170
|
+
.catch(function (error) {
|
171
|
+
console.log(error);
|
172
|
+
});
|
173
|
+
```
|
174
|
+
|
175
|
+
Performing multiple concurrent requests
|
176
|
+
|
177
|
+
```js
|
178
|
+
function getUserAccount() {
|
179
|
+
return axios.get('/user/12345');
|
180
|
+
}
|
181
|
+
|
182
|
+
function getUserPermissions() {
|
183
|
+
return axios.get('/user/12345/permissions');
|
184
|
+
}
|
185
|
+
|
186
|
+
Promise.all([getUserAccount(), getUserPermissions()])
|
187
|
+
.then(function (results) {
|
188
|
+
const acct = results[0];
|
189
|
+
const perm = results[1];
|
190
|
+
});
|
191
|
+
```
|
192
|
+
|
193
|
+
## axios API
|
194
|
+
|
195
|
+
Requests can be made by passing the relevant config to `axios`.
|
196
|
+
|
197
|
+
##### axios(config)
|
198
|
+
|
199
|
+
```js
|
200
|
+
// Send a POST request
|
201
|
+
axios({
|
202
|
+
method: 'post',
|
203
|
+
url: '/user/12345',
|
204
|
+
data: {
|
205
|
+
firstName: 'Fred',
|
206
|
+
lastName: 'Flintstone'
|
207
|
+
}
|
208
|
+
});
|
209
|
+
```
|
210
|
+
|
211
|
+
```js
|
212
|
+
// GET request for remote image in node.js
|
213
|
+
axios({
|
214
|
+
method: 'get',
|
215
|
+
url: 'http://bit.ly/2mTM3nY',
|
216
|
+
responseType: 'stream'
|
217
|
+
})
|
218
|
+
.then(function (response) {
|
219
|
+
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
|
220
|
+
});
|
221
|
+
```
|
222
|
+
|
223
|
+
##### axios(url[, config])
|
224
|
+
|
225
|
+
```js
|
226
|
+
// Send a GET request (default method)
|
227
|
+
axios('/user/12345');
|
228
|
+
```
|
229
|
+
|
230
|
+
### Request method aliases
|
231
|
+
|
232
|
+
For convenience aliases have been provided for all supported request methods.
|
233
|
+
|
234
|
+
##### axios.request(config)
|
235
|
+
##### axios.get(url[, config])
|
236
|
+
##### axios.delete(url[, config])
|
237
|
+
##### axios.head(url[, config])
|
238
|
+
##### axios.options(url[, config])
|
239
|
+
##### axios.post(url[, data[, config]])
|
240
|
+
##### axios.put(url[, data[, config]])
|
241
|
+
##### axios.patch(url[, data[, config]])
|
242
|
+
|
243
|
+
###### NOTE
|
244
|
+
When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config.
|
245
|
+
|
246
|
+
### Concurrency (Deprecated)
|
247
|
+
Please use `Promise.all` to replace the below functions.
|
248
|
+
|
249
|
+
Helper functions for dealing with concurrent requests.
|
250
|
+
|
251
|
+
axios.all(iterable)
|
252
|
+
axios.spread(callback)
|
253
|
+
|
254
|
+
### Creating an instance
|
255
|
+
|
256
|
+
You can create a new instance of axios with a custom config.
|
257
|
+
|
258
|
+
##### axios.create([config])
|
259
|
+
|
260
|
+
```js
|
261
|
+
const instance = axios.create({
|
262
|
+
baseURL: 'https://some-domain.com/api/',
|
263
|
+
timeout: 1000,
|
264
|
+
headers: {'X-Custom-Header': 'foobar'}
|
265
|
+
});
|
266
|
+
```
|
267
|
+
|
268
|
+
### Instance methods
|
269
|
+
|
270
|
+
The available instance methods are listed below. The specified config will be merged with the instance config.
|
271
|
+
|
272
|
+
##### axios#request(config)
|
273
|
+
##### axios#get(url[, config])
|
274
|
+
##### axios#delete(url[, config])
|
275
|
+
##### axios#head(url[, config])
|
276
|
+
##### axios#options(url[, config])
|
277
|
+
##### axios#post(url[, data[, config]])
|
278
|
+
##### axios#put(url[, data[, config]])
|
279
|
+
##### axios#patch(url[, data[, config]])
|
280
|
+
##### axios#getUri([config])
|
281
|
+
|
282
|
+
## Request Config
|
283
|
+
|
284
|
+
These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified.
|
285
|
+
|
286
|
+
```js
|
287
|
+
{
|
288
|
+
// `url` is the server URL that will be used for the request
|
289
|
+
url: '/user',
|
290
|
+
|
291
|
+
// `method` is the request method to be used when making the request
|
292
|
+
method: 'get', // default
|
293
|
+
|
294
|
+
// `baseURL` will be prepended to `url` unless `url` is absolute.
|
295
|
+
// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
|
296
|
+
// to methods of that instance.
|
297
|
+
baseURL: 'https://some-domain.com/api/',
|
298
|
+
|
299
|
+
// `transformRequest` allows changes to the request data before it is sent to the server
|
300
|
+
// This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE'
|
301
|
+
// The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
|
302
|
+
// FormData or Stream
|
303
|
+
// You may modify the headers object.
|
304
|
+
transformRequest: [function (data, headers) {
|
305
|
+
// Do whatever you want to transform the data
|
306
|
+
|
307
|
+
return data;
|
308
|
+
}],
|
309
|
+
|
310
|
+
// `transformResponse` allows changes to the response data to be made before
|
311
|
+
// it is passed to then/catch
|
312
|
+
transformResponse: [function (data) {
|
313
|
+
// Do whatever you want to transform the data
|
314
|
+
|
315
|
+
return data;
|
316
|
+
}],
|
317
|
+
|
318
|
+
// `headers` are custom headers to be sent
|
319
|
+
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
320
|
+
|
321
|
+
// `params` are the URL parameters to be sent with the request
|
322
|
+
// Must be a plain object or a URLSearchParams object
|
323
|
+
params: {
|
324
|
+
ID: 12345
|
325
|
+
},
|
326
|
+
|
327
|
+
// `paramsSerializer` is an optional function in charge of serializing `params`
|
328
|
+
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
|
329
|
+
paramsSerializer: function (params) {
|
330
|
+
return Qs.stringify(params, {arrayFormat: 'brackets'})
|
331
|
+
},
|
332
|
+
|
333
|
+
// `data` is the data to be sent as the request body
|
334
|
+
// Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'
|
335
|
+
// When no `transformRequest` is set, must be of one of the following types:
|
336
|
+
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
|
337
|
+
// - Browser only: FormData, File, Blob
|
338
|
+
// - Node only: Stream, Buffer
|
339
|
+
data: {
|
340
|
+
firstName: 'Fred'
|
341
|
+
},
|
342
|
+
|
343
|
+
// syntax alternative to send data into the body
|
344
|
+
// method post
|
345
|
+
// only the value is sent, not the key
|
346
|
+
data: 'Country=Brasil&City=Belo Horizonte',
|
347
|
+
|
348
|
+
// `timeout` specifies the number of milliseconds before the request times out.
|
349
|
+
// If the request takes longer than `timeout`, the request will be aborted.
|
350
|
+
timeout: 1000, // default is `0` (no timeout)
|
351
|
+
|
352
|
+
// `withCredentials` indicates whether or not cross-site Access-Control requests
|
353
|
+
// should be made using credentials
|
354
|
+
withCredentials: false, // default
|
355
|
+
|
356
|
+
// `adapter` allows custom handling of requests which makes testing easier.
|
357
|
+
// Return a promise and supply a valid response (see lib/adapters/README.md).
|
358
|
+
adapter: function (config) {
|
359
|
+
/* ... */
|
360
|
+
},
|
361
|
+
|
362
|
+
// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
|
363
|
+
// This will set an `Authorization` header, overwriting any existing
|
364
|
+
// `Authorization` custom headers you have set using `headers`.
|
365
|
+
// Please note that only HTTP Basic auth is configurable through this parameter.
|
366
|
+
// For Bearer tokens and such, use `Authorization` custom headers instead.
|
367
|
+
auth: {
|
368
|
+
username: 'janedoe',
|
369
|
+
password: 's00pers3cret'
|
370
|
+
},
|
371
|
+
|
372
|
+
// `responseType` indicates the type of data that the server will respond with
|
373
|
+
// options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
|
374
|
+
// browser only: 'blob'
|
375
|
+
responseType: 'json', // default
|
376
|
+
|
377
|
+
// `responseEncoding` indicates encoding to use for decoding responses (Node.js only)
|
378
|
+
// Note: Ignored for `responseType` of 'stream' or client-side requests
|
379
|
+
responseEncoding: 'utf8', // default
|
380
|
+
|
381
|
+
// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
|
382
|
+
xsrfCookieName: 'XSRF-TOKEN', // default
|
383
|
+
|
384
|
+
// `xsrfHeaderName` is the name of the http header that carries the xsrf token value
|
385
|
+
xsrfHeaderName: 'X-XSRF-TOKEN', // default
|
386
|
+
|
387
|
+
// `onUploadProgress` allows handling of progress events for uploads
|
388
|
+
// browser only
|
389
|
+
onUploadProgress: function (progressEvent) {
|
390
|
+
// Do whatever you want with the native progress event
|
391
|
+
},
|
392
|
+
|
393
|
+
// `onDownloadProgress` allows handling of progress events for downloads
|
394
|
+
// browser only
|
395
|
+
onDownloadProgress: function (progressEvent) {
|
396
|
+
// Do whatever you want with the native progress event
|
397
|
+
},
|
398
|
+
|
399
|
+
// `maxContentLength` defines the max size of the http response content in bytes allowed in node.js
|
400
|
+
maxContentLength: 2000,
|
401
|
+
|
402
|
+
// `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed
|
403
|
+
maxBodyLength: 2000,
|
404
|
+
|
405
|
+
// `validateStatus` defines whether to resolve or reject the promise for a given
|
406
|
+
// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
|
407
|
+
// or `undefined`), the promise will be resolved; otherwise, the promise will be
|
408
|
+
// rejected.
|
409
|
+
validateStatus: function (status) {
|
410
|
+
return status >= 200 && status < 300; // default
|
411
|
+
},
|
412
|
+
|
413
|
+
// `maxRedirects` defines the maximum number of redirects to follow in node.js.
|
414
|
+
// If set to 0, no redirects will be followed.
|
415
|
+
maxRedirects: 5, // default
|
416
|
+
|
417
|
+
// `socketPath` defines a UNIX Socket to be used in node.js.
|
418
|
+
// e.g. '/var/run/docker.sock' to send requests to the docker daemon.
|
419
|
+
// Only either `socketPath` or `proxy` can be specified.
|
420
|
+
// If both are specified, `socketPath` is used.
|
421
|
+
socketPath: null, // default
|
422
|
+
|
423
|
+
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
424
|
+
// and https requests, respectively, in node.js. This allows options to be added like
|
425
|
+
// `keepAlive` that are not enabled by default.
|
426
|
+
httpAgent: new http.Agent({ keepAlive: true }),
|
427
|
+
httpsAgent: new https.Agent({ keepAlive: true }),
|
428
|
+
|
429
|
+
// `proxy` defines the hostname, port, and protocol of the proxy server.
|
430
|
+
// You can also define your proxy using the conventional `http_proxy` and
|
431
|
+
// `https_proxy` environment variables. If you are using environment variables
|
432
|
+
// for your proxy configuration, you can also define a `no_proxy` environment
|
433
|
+
// variable as a comma-separated list of domains that should not be proxied.
|
434
|
+
// Use `false` to disable proxies, ignoring environment variables.
|
435
|
+
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
|
436
|
+
// supplies credentials.
|
437
|
+
// This will set an `Proxy-Authorization` header, overwriting any existing
|
438
|
+
// `Proxy-Authorization` custom headers you have set using `headers`.
|
439
|
+
// If the proxy server uses HTTPS, then you must set the protocol to `https`.
|
440
|
+
proxy: {
|
441
|
+
protocol: 'https',
|
442
|
+
host: '127.0.0.1',
|
443
|
+
port: 9000,
|
444
|
+
auth: {
|
445
|
+
username: 'mikeymike',
|
446
|
+
password: 'rapunz3l'
|
447
|
+
}
|
448
|
+
},
|
449
|
+
|
450
|
+
// `cancelToken` specifies a cancel token that can be used to cancel the request
|
451
|
+
// (see Cancellation section below for details)
|
452
|
+
cancelToken: new CancelToken(function (cancel) {
|
453
|
+
}),
|
454
|
+
|
455
|
+
// `decompress` indicates whether or not the response body should be decompressed
|
456
|
+
// automatically. If set to `true` will also remove the 'content-encoding' header
|
457
|
+
// from the responses objects of all decompressed responses
|
458
|
+
// - Node only (XHR cannot turn off decompression)
|
459
|
+
decompress: true, // default
|
460
|
+
|
461
|
+
// transitional options for backward compatibility that may be removed in the newer versions
|
462
|
+
transitional: {
|
463
|
+
// silent JSON parsing mode
|
464
|
+
// `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)
|
465
|
+
// `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json')
|
466
|
+
silentJSONParsing: true, // default value for the current Axios version
|
467
|
+
|
468
|
+
// try to parse the response string as JSON even if `responseType` is not 'json'
|
469
|
+
forcedJSONParsing: true,
|
470
|
+
|
471
|
+
// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
|
472
|
+
clarifyTimeoutError: false,
|
473
|
+
}
|
474
|
+
}
|
475
|
+
```
|
476
|
+
|
477
|
+
## Response Schema
|
478
|
+
|
479
|
+
The response for a request contains the following information.
|
480
|
+
|
481
|
+
```js
|
482
|
+
{
|
483
|
+
// `data` is the response that was provided by the server
|
484
|
+
data: {},
|
485
|
+
|
486
|
+
// `status` is the HTTP status code from the server response
|
487
|
+
status: 200,
|
488
|
+
|
489
|
+
// `statusText` is the HTTP status message from the server response
|
490
|
+
statusText: 'OK',
|
491
|
+
|
492
|
+
// `headers` the HTTP headers that the server responded with
|
493
|
+
// All header names are lower cased and can be accessed using the bracket notation.
|
494
|
+
// Example: `response.headers['content-type']`
|
495
|
+
headers: {},
|
496
|
+
|
497
|
+
// `config` is the config that was provided to `axios` for the request
|
498
|
+
config: {},
|
499
|
+
|
500
|
+
// `request` is the request that generated this response
|
501
|
+
// It is the last ClientRequest instance in node.js (in redirects)
|
502
|
+
// and an XMLHttpRequest instance in the browser
|
503
|
+
request: {}
|
504
|
+
}
|
505
|
+
```
|
506
|
+
|
507
|
+
When using `then`, you will receive the response as follows:
|
508
|
+
|
509
|
+
```js
|
510
|
+
axios.get('/user/12345')
|
511
|
+
.then(function (response) {
|
512
|
+
console.log(response.data);
|
513
|
+
console.log(response.status);
|
514
|
+
console.log(response.statusText);
|
515
|
+
console.log(response.headers);
|
516
|
+
console.log(response.config);
|
517
|
+
});
|
518
|
+
```
|
519
|
+
|
520
|
+
When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as second parameter of `then`, the response will be available through the `error` object as explained in the [Handling Errors](#handling-errors) section.
|
521
|
+
|
522
|
+
## Config Defaults
|
523
|
+
|
524
|
+
You can specify config defaults that will be applied to every request.
|
525
|
+
|
526
|
+
### Global axios defaults
|
527
|
+
|
528
|
+
```js
|
529
|
+
axios.defaults.baseURL = 'https://api.example.com';
|
530
|
+
|
531
|
+
// Important: If axios is used with multiple domains, the AUTH_TOKEN will be sent to all of them.
|
532
|
+
// See below for an example using Custom instance defaults instead.
|
533
|
+
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
534
|
+
|
535
|
+
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
536
|
+
```
|
537
|
+
|
538
|
+
### Custom instance defaults
|
539
|
+
|
540
|
+
```js
|
541
|
+
// Set config defaults when creating the instance
|
542
|
+
const instance = axios.create({
|
543
|
+
baseURL: 'https://api.example.com'
|
544
|
+
});
|
545
|
+
|
546
|
+
// Alter defaults after instance has been created
|
547
|
+
instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
548
|
+
```
|
549
|
+
|
550
|
+
### Config order of precedence
|
551
|
+
|
552
|
+
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.
|
553
|
+
|
554
|
+
```js
|
555
|
+
// Create an instance using the config defaults provided by the library
|
556
|
+
// At this point the timeout config value is `0` as is the default for the library
|
557
|
+
const instance = axios.create();
|
558
|
+
|
559
|
+
// Override timeout default for the library
|
560
|
+
// Now all requests using this instance will wait 2.5 seconds before timing out
|
561
|
+
instance.defaults.timeout = 2500;
|
562
|
+
|
563
|
+
// Override timeout for this request as it's known to take a long time
|
564
|
+
instance.get('/longRequest', {
|
565
|
+
timeout: 5000
|
566
|
+
});
|
567
|
+
```
|
568
|
+
|
569
|
+
## Interceptors
|
570
|
+
|
571
|
+
You can intercept requests or responses before they are handled by `then` or `catch`.
|
572
|
+
|
573
|
+
```js
|
574
|
+
// Add a request interceptor
|
575
|
+
axios.interceptors.request.use(function (config) {
|
576
|
+
// Do something before request is sent
|
577
|
+
return config;
|
578
|
+
}, function (error) {
|
579
|
+
// Do something with request error
|
580
|
+
return Promise.reject(error);
|
581
|
+
});
|
582
|
+
|
583
|
+
// Add a response interceptor
|
584
|
+
axios.interceptors.response.use(function (response) {
|
585
|
+
// Any status code that lie within the range of 2xx cause this function to trigger
|
586
|
+
// Do something with response data
|
587
|
+
return response;
|
588
|
+
}, function (error) {
|
589
|
+
// Any status codes that falls outside the range of 2xx cause this function to trigger
|
590
|
+
// Do something with response error
|
591
|
+
return Promise.reject(error);
|
592
|
+
});
|
593
|
+
```
|
594
|
+
|
595
|
+
If you need to remove an interceptor later you can.
|
596
|
+
|
597
|
+
```js
|
598
|
+
const myInterceptor = axios.interceptors.request.use(function () {/*...*/});
|
599
|
+
axios.interceptors.request.eject(myInterceptor);
|
600
|
+
```
|
601
|
+
|
602
|
+
You can add interceptors to a custom instance of axios.
|
603
|
+
|
604
|
+
```js
|
605
|
+
const instance = axios.create();
|
606
|
+
instance.interceptors.request.use(function () {/*...*/});
|
607
|
+
```
|
608
|
+
|
609
|
+
When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay
|
610
|
+
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for
|
611
|
+
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
|
612
|
+
to the options object that will tell axios to run the code synchronously and avoid any delays in request execution.
|
613
|
+
|
614
|
+
```js
|
615
|
+
axios.interceptors.request.use(function (config) {
|
616
|
+
config.headers.test = 'I am only a header!';
|
617
|
+
return config;
|
618
|
+
}, null, { synchronous: true });
|
619
|
+
```
|
620
|
+
|
621
|
+
If you want to execute a particular interceptor based on a runtime check,
|
622
|
+
you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return
|
623
|
+
of `runWhen` is `false`. The function will be called with the config
|
624
|
+
object (don't forget that you can bind your own arguments to it as well.) This can be handy when you have an
|
625
|
+
asynchronous request interceptor that only needs to run at certain times.
|
626
|
+
|
627
|
+
```js
|
628
|
+
function onGetCall(config) {
|
629
|
+
return config.method === 'get';
|
630
|
+
}
|
631
|
+
axios.interceptors.request.use(function (config) {
|
632
|
+
config.headers.test = 'special get headers';
|
633
|
+
return config;
|
634
|
+
}, null, { runWhen: onGetCall });
|
635
|
+
```
|
636
|
+
|
637
|
+
## Handling Errors
|
638
|
+
|
639
|
+
```js
|
640
|
+
axios.get('/user/12345')
|
641
|
+
.catch(function (error) {
|
642
|
+
if (error.response) {
|
643
|
+
// The request was made and the server responded with a status code
|
644
|
+
// that falls out of the range of 2xx
|
645
|
+
console.log(error.response.data);
|
646
|
+
console.log(error.response.status);
|
647
|
+
console.log(error.response.headers);
|
648
|
+
} else if (error.request) {
|
649
|
+
// The request was made but no response was received
|
650
|
+
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
651
|
+
// http.ClientRequest in node.js
|
652
|
+
console.log(error.request);
|
653
|
+
} else {
|
654
|
+
// Something happened in setting up the request that triggered an Error
|
655
|
+
console.log('Error', error.message);
|
656
|
+
}
|
657
|
+
console.log(error.config);
|
658
|
+
});
|
659
|
+
```
|
660
|
+
|
661
|
+
Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error.
|
662
|
+
|
663
|
+
```js
|
664
|
+
axios.get('/user/12345', {
|
665
|
+
validateStatus: function (status) {
|
666
|
+
return status < 500; // Resolve only if the status code is less than 500
|
667
|
+
}
|
668
|
+
})
|
669
|
+
```
|
670
|
+
|
671
|
+
Using `toJSON` you get an object with more information about the HTTP error.
|
672
|
+
|
673
|
+
```js
|
674
|
+
axios.get('/user/12345')
|
675
|
+
.catch(function (error) {
|
676
|
+
console.log(error.toJSON());
|
677
|
+
});
|
678
|
+
```
|
679
|
+
|
680
|
+
## Cancellation
|
681
|
+
|
682
|
+
You can cancel a request using a *cancel token*.
|
683
|
+
|
684
|
+
> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises).
|
685
|
+
|
686
|
+
You can create a cancel token using the `CancelToken.source` factory as shown below:
|
687
|
+
|
688
|
+
```js
|
689
|
+
const CancelToken = axios.CancelToken;
|
690
|
+
const source = CancelToken.source();
|
691
|
+
|
692
|
+
axios.get('/user/12345', {
|
693
|
+
cancelToken: source.token
|
694
|
+
}).catch(function (thrown) {
|
695
|
+
if (axios.isCancel(thrown)) {
|
696
|
+
console.log('Request canceled', thrown.message);
|
697
|
+
} else {
|
698
|
+
// handle error
|
699
|
+
}
|
700
|
+
});
|
701
|
+
|
702
|
+
axios.post('/user/12345', {
|
703
|
+
name: 'new name'
|
704
|
+
}, {
|
705
|
+
cancelToken: source.token
|
706
|
+
})
|
707
|
+
|
708
|
+
// cancel the request (the message parameter is optional)
|
709
|
+
source.cancel('Operation canceled by the user.');
|
710
|
+
```
|
711
|
+
|
712
|
+
You can also create a cancel token by passing an executor function to the `CancelToken` constructor:
|
713
|
+
|
714
|
+
```js
|
715
|
+
const CancelToken = axios.CancelToken;
|
716
|
+
let cancel;
|
717
|
+
|
718
|
+
axios.get('/user/12345', {
|
719
|
+
cancelToken: new CancelToken(function executor(c) {
|
720
|
+
// An executor function receives a cancel function as a parameter
|
721
|
+
cancel = c;
|
722
|
+
})
|
723
|
+
});
|
724
|
+
|
725
|
+
// cancel the request
|
726
|
+
cancel();
|
727
|
+
```
|
728
|
+
|
729
|
+
> Note: you can cancel several requests with the same cancel token.
|
730
|
+
> 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.
|
731
|
+
|
732
|
+
## Using application/x-www-form-urlencoded format
|
733
|
+
|
734
|
+
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.
|
735
|
+
|
736
|
+
### Browser
|
737
|
+
|
738
|
+
In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows:
|
739
|
+
|
740
|
+
```js
|
741
|
+
const params = new URLSearchParams();
|
742
|
+
params.append('param1', 'value1');
|
743
|
+
params.append('param2', 'value2');
|
744
|
+
axios.post('/foo', params);
|
745
|
+
```
|
746
|
+
|
747
|
+
> 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).
|
748
|
+
|
749
|
+
Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library:
|
750
|
+
|
751
|
+
```js
|
752
|
+
const qs = require('qs');
|
753
|
+
axios.post('/foo', qs.stringify({ 'bar': 123 }));
|
754
|
+
```
|
755
|
+
|
756
|
+
Or in another way (ES6),
|
757
|
+
|
758
|
+
```js
|
759
|
+
import qs from 'qs';
|
760
|
+
const data = { 'bar': 123 };
|
761
|
+
const options = {
|
762
|
+
method: 'POST',
|
763
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
764
|
+
data: qs.stringify(data),
|
765
|
+
url,
|
766
|
+
};
|
767
|
+
axios(options);
|
768
|
+
```
|
769
|
+
|
770
|
+
### Node.js
|
771
|
+
|
772
|
+
#### Query string
|
773
|
+
|
774
|
+
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
|
775
|
+
|
776
|
+
```js
|
777
|
+
const querystring = require('querystring');
|
778
|
+
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
|
779
|
+
```
|
780
|
+
|
781
|
+
or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows:
|
782
|
+
|
783
|
+
```js
|
784
|
+
const url = require('url');
|
785
|
+
const params = new url.URLSearchParams({ foo: 'bar' });
|
786
|
+
axios.post('http://something.com/', params.toString());
|
787
|
+
```
|
788
|
+
|
789
|
+
You can also use the [`qs`](https://github.com/ljharb/qs) library.
|
790
|
+
|
791
|
+
###### NOTE
|
792
|
+
The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665).
|
793
|
+
|
794
|
+
#### Form data
|
795
|
+
|
796
|
+
In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows:
|
797
|
+
|
798
|
+
```js
|
799
|
+
const FormData = require('form-data');
|
800
|
+
|
801
|
+
const form = new FormData();
|
802
|
+
form.append('my_field', 'my value');
|
803
|
+
form.append('my_buffer', new Buffer(10));
|
804
|
+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
805
|
+
|
806
|
+
axios.post('https://example.com', form, { headers: form.getHeaders() })
|
807
|
+
```
|
808
|
+
|
809
|
+
Alternatively, use an interceptor:
|
810
|
+
|
811
|
+
```js
|
812
|
+
axios.interceptors.request.use(config => {
|
813
|
+
if (config.data instanceof FormData) {
|
814
|
+
Object.assign(config.headers, config.data.getHeaders());
|
815
|
+
}
|
816
|
+
return config;
|
817
|
+
});
|
818
|
+
```
|
819
|
+
|
820
|
+
## Semver
|
821
|
+
|
822
|
+
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.
|
823
|
+
|
824
|
+
## Promises
|
825
|
+
|
826
|
+
axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises).
|
827
|
+
If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
|
828
|
+
|
829
|
+
## TypeScript
|
830
|
+
|
831
|
+
axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors.
|
832
|
+
|
833
|
+
```typescript
|
834
|
+
let user: User = null;
|
835
|
+
try {
|
836
|
+
const { data } = await axios.get('/user?ID=12345');
|
837
|
+
user = data.userDetails;
|
838
|
+
} catch (error) {
|
839
|
+
if (axios.isAxiosError(error)) {
|
840
|
+
handleAxiosError(error);
|
841
|
+
} else {
|
842
|
+
handleUnexpectedError(error);
|
843
|
+
}
|
844
|
+
}
|
845
|
+
```
|
846
|
+
|
847
|
+
## Online one-click setup
|
848
|
+
|
849
|
+
You can use Gitpod an online IDE(which is free for Open Source) for contributing or running the examples online.
|
850
|
+
|
851
|
+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js)
|
852
|
+
|
853
|
+
|
854
|
+
## Resources
|
855
|
+
|
856
|
+
* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
|
857
|
+
* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md)
|
858
|
+
* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md)
|
859
|
+
* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md)
|
860
|
+
* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md)
|
861
|
+
|
862
|
+
## Credits
|
863
|
+
|
864
|
+
axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular.
|
865
|
+
|
866
|
+
## License
|
867
|
+
|
868
|
+
[MIT](LICENSE)
|