@readme/httpsnippet 3.1.3 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -62
- package/dist/package.json +86 -0
- package/dist/src/fixtures/customTarget.js +15 -0
- package/dist/src/fixtures/mimetypes.js +77 -0
- package/dist/src/fixtures/requests/application-form-encoded.js +69 -0
- package/dist/src/fixtures/requests/application-json.js +72 -0
- package/dist/src/fixtures/requests/cookies.js +51 -0
- package/dist/src/fixtures/requests/custom-method.js +41 -0
- package/dist/src/fixtures/requests/full.js +99 -0
- package/dist/src/fixtures/requests/headers.js +56 -0
- package/dist/src/fixtures/requests/http-insecure.js +45 -0
- package/dist/src/fixtures/requests/jsonObj-multiline.js +59 -0
- package/dist/src/fixtures/requests/jsonObj-null-value.js +61 -0
- package/dist/src/fixtures/requests/multipart-data.js +72 -0
- package/dist/src/fixtures/requests/multipart-file.js +65 -0
- package/dist/src/fixtures/requests/multipart-form-data-no-params.js +56 -0
- package/dist/src/fixtures/requests/multipart-form-data.js +64 -0
- package/dist/src/fixtures/requests/nested.js +64 -0
- package/dist/src/fixtures/requests/query-encoded.js +59 -0
- package/dist/src/fixtures/requests/query.js +64 -0
- package/dist/src/fixtures/requests/short.js +45 -0
- package/dist/src/fixtures/requests/text-plain.js +57 -0
- package/dist/src/fixtures/runCustomFixtures.js +77 -0
- package/dist/src/helpers/code-builder.js +91 -0
- package/dist/src/helpers/form-data.js +157 -0
- package/dist/src/helpers/har-validator.js +76 -0
- package/dist/src/helpers/headers.js +33 -0
- package/dist/src/helpers/reducer.js +19 -0
- package/dist/src/helpers/shell.js +20 -0
- package/dist/src/helpers/utils.js +21 -0
- package/dist/src/index.js +285 -0
- package/dist/src/targets/c/libcurl/client.js +43 -0
- package/dist/src/targets/c/target.js +15 -0
- package/dist/src/targets/clojure/clj_http/client.js +184 -0
- package/dist/src/targets/clojure/target.js +15 -0
- package/dist/src/targets/csharp/httpclient/client.js +162 -0
- package/dist/src/targets/csharp/restsharp/client.js +38 -0
- package/dist/src/targets/csharp/target.js +17 -0
- package/dist/src/targets/go/native/client.js +122 -0
- package/dist/src/targets/go/target.js +15 -0
- package/dist/src/targets/http/http1.1/client.js +79 -0
- package/dist/src/targets/http/target.js +15 -0
- package/dist/src/targets/java/asynchttp/client.js +53 -0
- package/dist/src/targets/java/nethttp/client.js +52 -0
- package/dist/src/targets/java/okhttp/client.js +79 -0
- package/dist/src/targets/java/target.js +21 -0
- package/dist/src/targets/java/unirest/client.js +53 -0
- package/dist/src/targets/javascript/axios/client.js +101 -0
- package/dist/src/targets/javascript/axios/fixtures/application-form-encoded.js +22 -0
- package/dist/src/targets/javascript/axios/fixtures/application-json.js +26 -0
- package/dist/src/targets/javascript/axios/fixtures/cookies.js +18 -0
- package/dist/src/targets/javascript/axios/fixtures/custom-method.js +14 -0
- package/dist/src/targets/javascript/axios/fixtures/full.js +26 -0
- package/dist/src/targets/javascript/axios/fixtures/headers.js +18 -0
- package/dist/src/targets/javascript/axios/fixtures/http-insecure.js +14 -0
- package/dist/src/targets/javascript/axios/fixtures/jsonObj-multiline.js +19 -0
- package/dist/src/targets/javascript/axios/fixtures/jsonObj-null-value.js +19 -0
- package/dist/src/targets/javascript/axios/fixtures/multipart-data.js +22 -0
- package/dist/src/targets/javascript/axios/fixtures/multipart-file.js +21 -0
- package/dist/src/targets/javascript/axios/fixtures/multipart-form-data-no-params.js +18 -0
- package/dist/src/targets/javascript/axios/fixtures/multipart-form-data.js +21 -0
- package/dist/src/targets/javascript/axios/fixtures/nested.js +18 -0
- package/dist/src/targets/javascript/axios/fixtures/query-encoded.js +21 -0
- package/dist/src/targets/javascript/axios/fixtures/query.js +18 -0
- package/dist/src/targets/javascript/axios/fixtures/short.js +14 -0
- package/dist/src/targets/javascript/axios/fixtures/text-plain.js +19 -0
- package/dist/src/targets/javascript/fetch/client.js +115 -0
- package/dist/src/targets/javascript/fetch/fixtures/application-form-encoded.js +9 -0
- package/dist/src/targets/javascript/fetch/fixtures/application-json.js +16 -0
- package/dist/src/targets/javascript/fetch/fixtures/cookies.js +5 -0
- package/dist/src/targets/javascript/fetch/fixtures/custom-method.js +5 -0
- package/dist/src/targets/javascript/fetch/fixtures/full.js +13 -0
- package/dist/src/targets/javascript/fetch/fixtures/headers.js +8 -0
- package/dist/src/targets/javascript/fetch/fixtures/http-insecure.js +5 -0
- package/dist/src/targets/javascript/fetch/fixtures/jsonObj-multiline.js +9 -0
- package/dist/src/targets/javascript/fetch/fixtures/jsonObj-null-value.js +9 -0
- package/dist/src/targets/javascript/fetch/fixtures/multipart-data.js +9 -0
- package/dist/src/targets/javascript/fetch/fixtures/multipart-file.js +8 -0
- package/dist/src/targets/javascript/fetch/fixtures/multipart-form-data-no-params.js +5 -0
- package/dist/src/targets/javascript/fetch/fixtures/multipart-form-data.js +8 -0
- package/dist/src/targets/javascript/fetch/fixtures/nested.js +5 -0
- package/dist/src/targets/javascript/fetch/fixtures/query-encoded.js +5 -0
- package/dist/src/targets/javascript/fetch/fixtures/query.js +5 -0
- package/dist/src/targets/javascript/fetch/fixtures/short.js +5 -0
- package/dist/src/targets/javascript/fetch/fixtures/text-plain.js +5 -0
- package/dist/src/targets/javascript/jquery/client.js +93 -0
- package/dist/src/targets/javascript/jquery/fixtures/application-form-encoded.js +17 -0
- package/dist/src/targets/javascript/jquery/fixtures/application-json.js +15 -0
- package/dist/src/targets/javascript/jquery/fixtures/cookies.js +13 -0
- package/dist/src/targets/javascript/jquery/fixtures/custom-method.js +11 -0
- package/dist/src/targets/javascript/jquery/fixtures/full.js +18 -0
- package/dist/src/targets/javascript/jquery/fixtures/headers.js +15 -0
- package/dist/src/targets/javascript/jquery/fixtures/http-insecure.js +11 -0
- package/dist/src/targets/javascript/jquery/fixtures/jsonObj-multiline.js +15 -0
- package/dist/src/targets/javascript/jquery/fixtures/jsonObj-null-value.js +15 -0
- package/dist/src/targets/javascript/jquery/fixtures/multipart-data.js +18 -0
- package/dist/src/targets/javascript/jquery/fixtures/multipart-file.js +17 -0
- package/dist/src/targets/javascript/jquery/fixtures/multipart-form-data-no-params.js +13 -0
- package/dist/src/targets/javascript/jquery/fixtures/multipart-form-data.js +17 -0
- package/dist/src/targets/javascript/jquery/fixtures/nested.js +11 -0
- package/dist/src/targets/javascript/jquery/fixtures/query-encoded.js +11 -0
- package/dist/src/targets/javascript/jquery/fixtures/query.js +11 -0
- package/dist/src/targets/javascript/jquery/fixtures/short.js +11 -0
- package/dist/src/targets/javascript/jquery/fixtures/text-plain.js +14 -0
- package/dist/src/targets/javascript/target.js +21 -0
- package/dist/src/targets/javascript/xhr/client.js +90 -0
- package/dist/src/targets/javascript/xhr/fixtures/application-form-encoded.js +12 -0
- package/dist/src/targets/javascript/xhr/fixtures/application-json.js +31 -0
- package/dist/src/targets/javascript/xhr/fixtures/cookies.js +12 -0
- package/dist/src/targets/javascript/xhr/fixtures/cors.js +10 -0
- package/dist/src/targets/javascript/xhr/fixtures/custom-method.js +11 -0
- package/dist/src/targets/javascript/xhr/fixtures/full.js +14 -0
- package/dist/src/targets/javascript/xhr/fixtures/headers.js +14 -0
- package/dist/src/targets/javascript/xhr/fixtures/http-insecure.js +11 -0
- package/dist/src/targets/javascript/xhr/fixtures/jsonObj-multiline.js +14 -0
- package/dist/src/targets/javascript/xhr/fixtures/jsonObj-null-value.js +14 -0
- package/dist/src/targets/javascript/xhr/fixtures/multipart-data.js +13 -0
- package/dist/src/targets/javascript/xhr/fixtures/multipart-file.js +12 -0
- package/dist/src/targets/javascript/xhr/fixtures/multipart-form-data-no-params.js +11 -0
- package/dist/src/targets/javascript/xhr/fixtures/multipart-form-data.js +12 -0
- package/dist/src/targets/javascript/xhr/fixtures/nested.js +11 -0
- package/dist/src/targets/javascript/xhr/fixtures/query-encoded.js +11 -0
- package/dist/src/targets/javascript/xhr/fixtures/query.js +11 -0
- package/dist/src/targets/javascript/xhr/fixtures/short.js +11 -0
- package/dist/src/targets/javascript/xhr/fixtures/text-plain.js +12 -0
- package/dist/src/targets/kotlin/okhttp/client.js +79 -0
- package/dist/src/targets/kotlin/target.js +15 -0
- package/dist/src/targets/node/axios/client.js +87 -0
- package/dist/src/targets/node/axios/fixtures/application-form-encoded.js +19 -0
- package/dist/src/targets/node/axios/fixtures/application-json.js +22 -0
- package/dist/src/targets/node/axios/fixtures/cookies.js +14 -0
- package/dist/src/targets/node/axios/fixtures/custom-method.js +10 -0
- package/dist/src/targets/node/axios/fixtures/full.js +22 -0
- package/dist/src/targets/node/axios/fixtures/headers.js +14 -0
- package/dist/src/targets/node/axios/fixtures/http-insecure.js +10 -0
- package/dist/src/targets/node/axios/fixtures/jsonObj-multiline.js +15 -0
- package/dist/src/targets/node/axios/fixtures/jsonObj-null-value.js +15 -0
- package/dist/src/targets/node/axios/fixtures/multipart-data.js +15 -0
- package/dist/src/targets/node/axios/fixtures/multipart-file.js +15 -0
- package/dist/src/targets/node/axios/fixtures/multipart-form-data-no-params.js +14 -0
- package/dist/src/targets/node/axios/fixtures/multipart-form-data.js +15 -0
- package/dist/src/targets/node/axios/fixtures/nested.js +13 -0
- package/dist/src/targets/node/axios/fixtures/query-encoded.js +13 -0
- package/dist/src/targets/node/axios/fixtures/query.js +13 -0
- package/dist/src/targets/node/axios/fixtures/short.js +10 -0
- package/dist/src/targets/node/axios/fixtures/text-plain.js +15 -0
- package/dist/src/targets/node/fetch/client.js +149 -0
- package/dist/src/targets/node/fetch/fixtures/application-form-encoded.js +15 -0
- package/dist/src/targets/node/fetch/fixtures/application-json.js +18 -0
- package/dist/src/targets/node/fetch/fixtures/cookies.js +7 -0
- package/dist/src/targets/node/fetch/fixtures/custom-method.js +7 -0
- package/dist/src/targets/node/fetch/fixtures/full.js +18 -0
- package/dist/src/targets/node/fetch/fixtures/headers.js +10 -0
- package/dist/src/targets/node/fetch/fixtures/http-insecure.js +7 -0
- package/dist/src/targets/node/fetch/fixtures/jsonObj-multiline.js +11 -0
- package/dist/src/targets/node/fetch/fixtures/jsonObj-null-value.js +11 -0
- package/dist/src/targets/node/fetch/fixtures/multipart-data.js +13 -0
- package/dist/src/targets/node/fetch/fixtures/multipart-file.js +12 -0
- package/dist/src/targets/node/fetch/fixtures/multipart-form-data-no-params.js +7 -0
- package/dist/src/targets/node/fetch/fixtures/multipart-form-data.js +11 -0
- package/dist/src/targets/node/fetch/fixtures/nested.js +7 -0
- package/dist/src/targets/node/fetch/fixtures/query-encoded.js +7 -0
- package/dist/src/targets/node/fetch/fixtures/query.js +7 -0
- package/dist/src/targets/node/fetch/fixtures/short.js +7 -0
- package/dist/src/targets/node/fetch/fixtures/text-plain.js +7 -0
- package/dist/src/targets/node/native/client.js +91 -0
- package/dist/src/targets/node/native/fixtures/application-form-encoded.js +24 -0
- package/dist/src/targets/node/native/fixtures/application-json.js +30 -0
- package/dist/src/targets/node/native/fixtures/cookies.js +22 -0
- package/dist/src/targets/node/native/fixtures/custom-method.js +20 -0
- package/dist/src/targets/node/native/fixtures/full.js +26 -0
- package/dist/src/targets/node/native/fixtures/headers.js +24 -0
- package/dist/src/targets/node/native/fixtures/http-insecure.js +20 -0
- package/dist/src/targets/node/native/fixtures/jsonObj-multiline.js +23 -0
- package/dist/src/targets/node/native/fixtures/jsonObj-null-value.js +23 -0
- package/dist/src/targets/node/native/fixtures/multipart-data.js +23 -0
- package/dist/src/targets/node/native/fixtures/multipart-file.js +23 -0
- package/dist/src/targets/node/native/fixtures/multipart-form-data-no-params.js +22 -0
- package/dist/src/targets/node/native/fixtures/multipart-form-data.js +23 -0
- package/dist/src/targets/node/native/fixtures/nested.js +20 -0
- package/dist/src/targets/node/native/fixtures/query-encoded.js +20 -0
- package/dist/src/targets/node/native/fixtures/query.js +20 -0
- package/dist/src/targets/node/native/fixtures/short.js +20 -0
- package/dist/src/targets/node/native/fixtures/text-plain.js +23 -0
- package/dist/src/targets/node/request/client.js +116 -0
- package/dist/src/targets/node/request/fixtures/application-form-encoded.js +13 -0
- package/dist/src/targets/node/request/fixtures/application-json.js +21 -0
- package/dist/src/targets/node/request/fixtures/cookies.js +11 -0
- package/dist/src/targets/node/request/fixtures/custom-method.js +8 -0
- package/dist/src/targets/node/request/fixtures/full.js +20 -0
- package/dist/src/targets/node/request/fixtures/headers.js +12 -0
- package/dist/src/targets/node/request/fixtures/http-insecure.js +8 -0
- package/dist/src/targets/node/request/fixtures/jsonObj-multiline.js +14 -0
- package/dist/src/targets/node/request/fixtures/jsonObj-null-value.js +14 -0
- package/dist/src/targets/node/request/fixtures/multipart-data.js +20 -0
- package/dist/src/targets/node/request/fixtures/multipart-file.js +19 -0
- package/dist/src/targets/node/request/fixtures/multipart-form-data-no-params.js +12 -0
- package/dist/src/targets/node/request/fixtures/multipart-form-data.js +13 -0
- package/dist/src/targets/node/request/fixtures/nested.js +11 -0
- package/dist/src/targets/node/request/fixtures/query-encoded.js +11 -0
- package/dist/src/targets/node/request/fixtures/query.js +11 -0
- package/dist/src/targets/node/request/fixtures/short.js +8 -0
- package/dist/src/targets/node/request/fixtures/text-plain.js +13 -0
- package/dist/src/targets/node/target.js +24 -0
- package/dist/src/targets/node/unirest/client.js +119 -0
- package/dist/src/targets/node/unirest/fixtures/application-form-encoded.js +15 -0
- package/dist/src/targets/node/unirest/fixtures/application-json.js +32 -0
- package/dist/src/targets/node/unirest/fixtures/cookies.js +12 -0
- package/dist/src/targets/node/unirest/fixtures/custom-method.js +8 -0
- package/dist/src/targets/node/unirest/fixtures/full.js +27 -0
- package/dist/src/targets/node/unirest/fixtures/headers.js +13 -0
- package/dist/src/targets/node/unirest/fixtures/http-insecure.js +8 -0
- package/dist/src/targets/node/unirest/fixtures/jsonObj-multiline.js +15 -0
- package/dist/src/targets/node/unirest/fixtures/jsonObj-null-value.js +15 -0
- package/dist/src/targets/node/unirest/fixtures/multipart-data.js +20 -0
- package/dist/src/targets/node/unirest/fixtures/multipart-file.js +18 -0
- package/dist/src/targets/node/unirest/fixtures/multipart-form-data-no-params.js +11 -0
- package/dist/src/targets/node/unirest/fixtures/multipart-form-data.js +16 -0
- package/dist/src/targets/node/unirest/fixtures/nested.js +13 -0
- package/dist/src/targets/node/unirest/fixtures/query-encoded.js +12 -0
- package/dist/src/targets/node/unirest/fixtures/query.js +16 -0
- package/dist/src/targets/node/unirest/fixtures/short.js +8 -0
- package/dist/src/targets/node/unirest/fixtures/text-plain.js +12 -0
- package/dist/src/targets/objc/helpers.js +59 -0
- package/dist/src/targets/objc/nsurlsession/client.js +151 -0
- package/dist/src/targets/objc/target.js +15 -0
- package/dist/src/targets/ocaml/cohttp/client.js +72 -0
- package/dist/src/targets/ocaml/target.js +15 -0
- package/dist/src/targets/php/curl/client.js +135 -0
- package/dist/src/targets/php/guzzle/client.js +126 -0
- package/dist/src/targets/php/helpers.js +63 -0
- package/dist/src/targets/php/http1/client.js +90 -0
- package/dist/src/targets/php/http2/client.js +128 -0
- package/dist/src/targets/php/target.js +22 -0
- package/dist/src/targets/powershell/common.js +49 -0
- package/dist/src/targets/powershell/restmethod/client.js +13 -0
- package/dist/src/targets/powershell/target.js +17 -0
- package/dist/src/targets/powershell/webrequest/client.js +13 -0
- package/dist/src/targets/python/helpers.js +70 -0
- package/dist/src/targets/python/requests/client.js +161 -0
- package/dist/src/targets/python/target.js +16 -0
- package/dist/src/targets/r/httr/client.js +125 -0
- package/dist/src/targets/r/target.js +15 -0
- package/dist/src/targets/ruby/native/client.js +69 -0
- package/dist/src/targets/ruby/target.js +15 -0
- package/dist/src/targets/shell/curl/client.js +171 -0
- package/dist/src/targets/shell/httpie/client.js +111 -0
- package/dist/src/targets/shell/target.js +20 -0
- package/dist/src/targets/shell/wget/client.js +55 -0
- package/dist/src/targets/swift/helpers.js +80 -0
- package/dist/src/targets/swift/nsurlsession/client.js +156 -0
- package/dist/src/targets/swift/target.js +15 -0
- package/dist/src/targets/targets.js +130 -0
- package/package.json +26 -21
- package/src/helpers/code-builder.js +0 -108
- package/src/helpers/form-data.js +0 -107
- package/src/helpers/headers.js +0 -48
- package/src/helpers/reducer.js +0 -20
- package/src/index.js +0 -361
- package/src/targets/c/index.js +0 -10
- package/src/targets/c/libcurl.js +0 -45
- package/src/targets/clojure/clj_http.js +0 -176
- package/src/targets/clojure/index.js +0 -10
- package/src/targets/csharp/httpclient.js +0 -157
- package/src/targets/csharp/index.js +0 -11
- package/src/targets/csharp/restsharp.js +0 -49
- package/src/targets/go/index.js +0 -10
- package/src/targets/go/native.js +0 -130
- package/src/targets/http/http1.1.js +0 -89
- package/src/targets/http/index.js +0 -10
- package/src/targets/index.js +0 -20
- package/src/targets/java/asynchttp.js +0 -54
- package/src/targets/java/index.js +0 -13
- package/src/targets/java/nethttp.js +0 -59
- package/src/targets/java/okhttp.js +0 -78
- package/src/targets/java/unirest.js +0 -57
- package/src/targets/javascript/axios.js +0 -101
- package/src/targets/javascript/fetch.js +0 -129
- package/src/targets/javascript/index.js +0 -13
- package/src/targets/javascript/jquery.js +0 -89
- package/src/targets/javascript/xhr.js +0 -86
- package/src/targets/kotlin/index.js +0 -10
- package/src/targets/kotlin/okhttp.js +0 -78
- package/src/targets/node/axios.js +0 -76
- package/src/targets/node/fetch.js +0 -145
- package/src/targets/node/index.js +0 -15
- package/src/targets/node/native.js +0 -92
- package/src/targets/node/request.js +0 -126
- package/src/targets/node/unirest.js +0 -120
- package/src/targets/objc/helpers.js +0 -80
- package/src/targets/objc/index.js +0 -10
- package/src/targets/objc/nsurlsession.js +0 -164
- package/src/targets/ocaml/cohttp.js +0 -73
- package/src/targets/ocaml/index.js +0 -10
- package/src/targets/php/curl.js +0 -142
- package/src/targets/php/guzzle.js +0 -135
- package/src/targets/php/helpers.js +0 -87
- package/src/targets/php/http1.js +0 -85
- package/src/targets/php/http2.js +0 -131
- package/src/targets/php/index.js +0 -14
- package/src/targets/powershell/common.js +0 -60
- package/src/targets/powershell/index.js +0 -11
- package/src/targets/powershell/restmethod.js +0 -8
- package/src/targets/powershell/webrequest.js +0 -8
- package/src/targets/python/helpers.js +0 -85
- package/src/targets/python/index.js +0 -11
- package/src/targets/python/requests.js +0 -163
- package/src/targets/r/httr.js +0 -134
- package/src/targets/r/index.js +0 -10
- package/src/targets/ruby/index.js +0 -10
- package/src/targets/ruby/native.js +0 -71
- package/src/targets/shell/curl.js +0 -157
- package/src/targets/shell/helpers.js +0 -23
- package/src/targets/shell/httpie.js +0 -129
- package/src/targets/shell/index.js +0 -13
- package/src/targets/shell/wget.js +0 -52
- package/src/targets/swift/helpers.js +0 -93
- package/src/targets/swift/index.js +0 -10
- package/src/targets/swift/nsurlsession.js +0 -152
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = 'foo=bar&hello=world';
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
11
|
+
xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
|
|
12
|
+
xhr.send(data);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = JSON.stringify({
|
|
3
|
+
number: 1,
|
|
4
|
+
string: 'f"oo',
|
|
5
|
+
arr: [
|
|
6
|
+
1,
|
|
7
|
+
2,
|
|
8
|
+
3
|
|
9
|
+
],
|
|
10
|
+
nested: {
|
|
11
|
+
a: 'b'
|
|
12
|
+
},
|
|
13
|
+
arr_mix: [
|
|
14
|
+
1,
|
|
15
|
+
'a',
|
|
16
|
+
{
|
|
17
|
+
arr_mix_nested: {}
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
boolean: false
|
|
21
|
+
});
|
|
22
|
+
var xhr = new XMLHttpRequest();
|
|
23
|
+
xhr.withCredentials = true;
|
|
24
|
+
xhr.addEventListener('readystatechange', function () {
|
|
25
|
+
if (this.readyState === this.DONE) {
|
|
26
|
+
console.log(this.responseText);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
30
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
31
|
+
xhr.send(data);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('GET', 'https://httpbin.org/cookies');
|
|
11
|
+
xhr.setRequestHeader('cookie', 'foo=bar; bar=baz');
|
|
12
|
+
xhr.send(data);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.addEventListener('readystatechange', function () {
|
|
5
|
+
if (this.readyState === this.DONE) {
|
|
6
|
+
console.log(this.responseText);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
xhr.open('GET', 'https://httpbin.org/anything');
|
|
10
|
+
xhr.send(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('PROPFIND', 'https://httpbin.org/anything');
|
|
11
|
+
xhr.send(data);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = 'foo=bar';
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('POST', 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value');
|
|
11
|
+
xhr.setRequestHeader('cookie', 'foo=bar; bar=baz');
|
|
12
|
+
xhr.setRequestHeader('accept', 'application/json');
|
|
13
|
+
xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
|
|
14
|
+
xhr.send(data);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('GET', 'https://httpbin.org/headers');
|
|
11
|
+
xhr.setRequestHeader('accept', 'application/json');
|
|
12
|
+
xhr.setRequestHeader('x-foo', 'Bar');
|
|
13
|
+
xhr.setRequestHeader('x-bar', 'Foo');
|
|
14
|
+
xhr.send(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('GET', 'http://httpbin.org/anything');
|
|
11
|
+
xhr.send(data);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = JSON.stringify({
|
|
3
|
+
foo: 'bar'
|
|
4
|
+
});
|
|
5
|
+
var xhr = new XMLHttpRequest();
|
|
6
|
+
xhr.withCredentials = true;
|
|
7
|
+
xhr.addEventListener('readystatechange', function () {
|
|
8
|
+
if (this.readyState === this.DONE) {
|
|
9
|
+
console.log(this.responseText);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
13
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
14
|
+
xhr.send(data);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = JSON.stringify({
|
|
3
|
+
foo: null
|
|
4
|
+
});
|
|
5
|
+
var xhr = new XMLHttpRequest();
|
|
6
|
+
xhr.withCredentials = true;
|
|
7
|
+
xhr.addEventListener('readystatechange', function () {
|
|
8
|
+
if (this.readyState === this.DONE) {
|
|
9
|
+
console.log(this.responseText);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
13
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
14
|
+
xhr.send(data);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = new FormData();
|
|
3
|
+
data.append('foo', 'Hello World');
|
|
4
|
+
data.append('bar', 'Bonjour le monde');
|
|
5
|
+
var xhr = new XMLHttpRequest();
|
|
6
|
+
xhr.withCredentials = true;
|
|
7
|
+
xhr.addEventListener('readystatechange', function () {
|
|
8
|
+
if (this.readyState === this.DONE) {
|
|
9
|
+
console.log(this.responseText);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
13
|
+
xhr.send(data);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = new FormData();
|
|
3
|
+
data.append('foo', 'src/fixtures/files/hello.txt');
|
|
4
|
+
var xhr = new XMLHttpRequest();
|
|
5
|
+
xhr.withCredentials = true;
|
|
6
|
+
xhr.addEventListener('readystatechange', function () {
|
|
7
|
+
if (this.readyState === this.DONE) {
|
|
8
|
+
console.log(this.responseText);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
12
|
+
xhr.send(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var xhr = new XMLHttpRequest();
|
|
3
|
+
xhr.withCredentials = true;
|
|
4
|
+
xhr.addEventListener('readystatechange', function () {
|
|
5
|
+
if (this.readyState === this.DONE) {
|
|
6
|
+
console.log(this.responseText);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
10
|
+
xhr.setRequestHeader('Content-Type', 'multipart/form-data');
|
|
11
|
+
xhr.send(data);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = new FormData();
|
|
3
|
+
data.append('foo', 'bar');
|
|
4
|
+
var xhr = new XMLHttpRequest();
|
|
5
|
+
xhr.withCredentials = true;
|
|
6
|
+
xhr.addEventListener('readystatechange', function () {
|
|
7
|
+
if (this.readyState === this.DONE) {
|
|
8
|
+
console.log(this.responseText);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
12
|
+
xhr.send(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('GET', 'https://httpbin.org/anything?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value');
|
|
11
|
+
xhr.send(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('GET', 'https://httpbin.org/anything?startTime=2019-06-13T19%3A08%3A25.455Z&endTime=2015-09-15T14%3A00%3A12-04%3A00');
|
|
11
|
+
xhr.send(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('GET', 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value');
|
|
11
|
+
xhr.send(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('GET', 'https://httpbin.org/anything');
|
|
11
|
+
xhr.send(data);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = 'Hello World';
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
11
|
+
xhr.setRequestHeader('content-type', 'text/plain');
|
|
12
|
+
xhr.send(data);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* HTTP code snippet generator for Kotlin using OkHttp.
|
|
5
|
+
*
|
|
6
|
+
* @author
|
|
7
|
+
* @seanghay
|
|
8
|
+
*
|
|
9
|
+
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
10
|
+
*/
|
|
11
|
+
var __assign = (this && this.__assign) || function () {
|
|
12
|
+
__assign = Object.assign || function(t) {
|
|
13
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
14
|
+
s = arguments[i];
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
}
|
|
18
|
+
return t;
|
|
19
|
+
};
|
|
20
|
+
return __assign.apply(this, arguments);
|
|
21
|
+
};
|
|
22
|
+
exports.__esModule = true;
|
|
23
|
+
exports.okhttp = void 0;
|
|
24
|
+
var code_builder_1 = require("../../../helpers/code-builder");
|
|
25
|
+
exports.okhttp = {
|
|
26
|
+
info: {
|
|
27
|
+
key: 'okhttp',
|
|
28
|
+
title: 'OkHttp',
|
|
29
|
+
link: 'http://square.github.io/okhttp/',
|
|
30
|
+
description: 'An HTTP Request Client Library'
|
|
31
|
+
},
|
|
32
|
+
convert: function (_a, options) {
|
|
33
|
+
var postData = _a.postData, fullUrl = _a.fullUrl, method = _a.method, allHeaders = _a.allHeaders;
|
|
34
|
+
var opts = __assign({ indent: ' ' }, options);
|
|
35
|
+
var _b = new code_builder_1.CodeBuilder({ indent: opts.indent }), blank = _b.blank, join = _b.join, push = _b.push;
|
|
36
|
+
var methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'];
|
|
37
|
+
var methodsWithBody = ['POST', 'PUT', 'DELETE', 'PATCH'];
|
|
38
|
+
push('val client = OkHttpClient()');
|
|
39
|
+
blank();
|
|
40
|
+
if (postData.text) {
|
|
41
|
+
if (postData.boundary) {
|
|
42
|
+
push("val mediaType = MediaType.parse(\"".concat(postData.mimeType, "; boundary=").concat(postData.boundary, "\")"));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
push("val mediaType = MediaType.parse(\"".concat(postData.mimeType, "\")"));
|
|
46
|
+
}
|
|
47
|
+
push("val body = RequestBody.create(mediaType, ".concat(JSON.stringify(postData.text), ")"));
|
|
48
|
+
}
|
|
49
|
+
push('val request = Request.Builder()');
|
|
50
|
+
push(".url(\"".concat(fullUrl, "\")"), 1);
|
|
51
|
+
if (!methods.includes(method.toUpperCase())) {
|
|
52
|
+
if (postData.text) {
|
|
53
|
+
push(".method(\"".concat(method.toUpperCase(), "\", body)"), 1);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
push(".method(\"".concat(method.toUpperCase(), "\", null)"), 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (methodsWithBody.includes(method.toUpperCase())) {
|
|
60
|
+
if (postData.text) {
|
|
61
|
+
push(".".concat(method.toLowerCase(), "(body)"), 1);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
push(".".concat(method.toLowerCase(), "(null)"), 1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
push(".".concat(method.toLowerCase(), "()"), 1);
|
|
69
|
+
}
|
|
70
|
+
// Add headers, including the cookies
|
|
71
|
+
Object.keys(allHeaders).forEach(function (key) {
|
|
72
|
+
push(".addHeader(\"".concat(key, "\", \"").concat(allHeaders[key], "\")"), 1);
|
|
73
|
+
});
|
|
74
|
+
push('.build()', 1);
|
|
75
|
+
blank();
|
|
76
|
+
push('val response = client.newCall(request).execute()');
|
|
77
|
+
return join();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.kotlin = void 0;
|
|
4
|
+
var client_1 = require("./okhttp/client");
|
|
5
|
+
exports.kotlin = {
|
|
6
|
+
info: {
|
|
7
|
+
key: 'kotlin',
|
|
8
|
+
title: 'Kotlin',
|
|
9
|
+
extname: '.kt',
|
|
10
|
+
"default": 'okhttp'
|
|
11
|
+
},
|
|
12
|
+
clientsById: {
|
|
13
|
+
okhttp: client_1.okhttp
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* HTTP code snippet generator for Javascript & Node.js using Axios.
|
|
5
|
+
*
|
|
6
|
+
* @author
|
|
7
|
+
* @rohit-gohri
|
|
8
|
+
*
|
|
9
|
+
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
10
|
+
*/
|
|
11
|
+
var __assign = (this && this.__assign) || function () {
|
|
12
|
+
__assign = Object.assign || function(t) {
|
|
13
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
14
|
+
s = arguments[i];
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
}
|
|
18
|
+
return t;
|
|
19
|
+
};
|
|
20
|
+
return __assign.apply(this, arguments);
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
exports.__esModule = true;
|
|
26
|
+
exports.axios = void 0;
|
|
27
|
+
var stringify_object_1 = __importDefault(require("stringify-object"));
|
|
28
|
+
var code_builder_1 = require("../../../helpers/code-builder");
|
|
29
|
+
exports.axios = {
|
|
30
|
+
info: {
|
|
31
|
+
key: 'axios',
|
|
32
|
+
title: 'Axios',
|
|
33
|
+
link: 'https://github.com/axios/axios',
|
|
34
|
+
description: 'Promise based HTTP client for the browser and node.js'
|
|
35
|
+
},
|
|
36
|
+
convert: function (_a, options) {
|
|
37
|
+
var method = _a.method, fullUrl = _a.fullUrl, allHeaders = _a.allHeaders, postData = _a.postData;
|
|
38
|
+
var opts = __assign({ indent: ' ' }, options);
|
|
39
|
+
var _b = new code_builder_1.CodeBuilder({ indent: opts.indent }), blank = _b.blank, join = _b.join, push = _b.push, addPostProcessor = _b.addPostProcessor;
|
|
40
|
+
push("const axios = require('axios').default;");
|
|
41
|
+
var reqOpts = {
|
|
42
|
+
method: method,
|
|
43
|
+
url: fullUrl
|
|
44
|
+
};
|
|
45
|
+
if (Object.keys(allHeaders).length) {
|
|
46
|
+
reqOpts.headers = allHeaders;
|
|
47
|
+
}
|
|
48
|
+
switch (postData.mimeType) {
|
|
49
|
+
case 'application/x-www-form-urlencoded':
|
|
50
|
+
if (postData.params) {
|
|
51
|
+
push("const { URLSearchParams } = require('url');");
|
|
52
|
+
blank();
|
|
53
|
+
push('const encodedParams = new URLSearchParams();');
|
|
54
|
+
postData.params.forEach(function (param) {
|
|
55
|
+
push("encodedParams.set('".concat(param.name, "', '").concat(param.value, "');"));
|
|
56
|
+
});
|
|
57
|
+
blank();
|
|
58
|
+
reqOpts.data = 'encodedParams,';
|
|
59
|
+
addPostProcessor(function (code) { return code.replace(/'encodedParams,'/, 'encodedParams,'); });
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case 'application/json':
|
|
63
|
+
blank();
|
|
64
|
+
if (postData.jsonObj) {
|
|
65
|
+
reqOpts.data = postData.jsonObj;
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
blank();
|
|
70
|
+
if (postData.text) {
|
|
71
|
+
reqOpts.data = postData.text;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
var stringifiedOptions = (0, stringify_object_1["default"])(reqOpts, { indent: ' ', inlineCharacterLimit: 80 });
|
|
75
|
+
push("const options = ".concat(stringifiedOptions, ";"));
|
|
76
|
+
blank();
|
|
77
|
+
push('axios');
|
|
78
|
+
push('.request(options)', 1);
|
|
79
|
+
push('.then(function (response) {', 1);
|
|
80
|
+
push('console.log(response.data);', 2);
|
|
81
|
+
push('})', 1);
|
|
82
|
+
push('.catch(function (error) {', 1);
|
|
83
|
+
push('console.error(error);', 2);
|
|
84
|
+
push('});', 1);
|
|
85
|
+
return join();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var URLSearchParams = require('url').URLSearchParams;
|
|
4
|
+
var encodedParams = new URLSearchParams();
|
|
5
|
+
encodedParams.set('foo', 'bar');
|
|
6
|
+
encodedParams.set('hello', 'world');
|
|
7
|
+
var options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
url: 'https://httpbin.org/anything',
|
|
10
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
11
|
+
data: encodedParams
|
|
12
|
+
};
|
|
13
|
+
axios
|
|
14
|
+
.request(options)
|
|
15
|
+
.then(function (response) {
|
|
16
|
+
console.log(response.data);
|
|
17
|
+
})["catch"](function (error) {
|
|
18
|
+
console.error(error);
|
|
19
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
url: 'https://httpbin.org/anything',
|
|
6
|
+
headers: { 'content-type': 'application/json' },
|
|
7
|
+
data: {
|
|
8
|
+
number: 1,
|
|
9
|
+
string: 'f"oo',
|
|
10
|
+
arr: [1, 2, 3],
|
|
11
|
+
nested: { a: 'b' },
|
|
12
|
+
arr_mix: [1, 'a', { arr_mix_nested: {} }],
|
|
13
|
+
boolean: false
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
axios
|
|
17
|
+
.request(options)
|
|
18
|
+
.then(function (response) {
|
|
19
|
+
console.log(response.data);
|
|
20
|
+
})["catch"](function (error) {
|
|
21
|
+
console.error(error);
|
|
22
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'GET',
|
|
5
|
+
url: 'https://httpbin.org/cookies',
|
|
6
|
+
headers: { cookie: 'foo=bar; bar=baz' }
|
|
7
|
+
};
|
|
8
|
+
axios
|
|
9
|
+
.request(options)
|
|
10
|
+
.then(function (response) {
|
|
11
|
+
console.log(response.data);
|
|
12
|
+
})["catch"](function (error) {
|
|
13
|
+
console.error(error);
|
|
14
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = { method: 'PROPFIND', url: 'https://httpbin.org/anything' };
|
|
4
|
+
axios
|
|
5
|
+
.request(options)
|
|
6
|
+
.then(function (response) {
|
|
7
|
+
console.log(response.data);
|
|
8
|
+
})["catch"](function (error) {
|
|
9
|
+
console.error(error);
|
|
10
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var URLSearchParams = require('url').URLSearchParams;
|
|
4
|
+
var encodedParams = new URLSearchParams();
|
|
5
|
+
encodedParams.set('foo', 'bar');
|
|
6
|
+
var options = {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
url: 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value',
|
|
9
|
+
headers: {
|
|
10
|
+
cookie: 'foo=bar; bar=baz',
|
|
11
|
+
accept: 'application/json',
|
|
12
|
+
'content-type': 'application/x-www-form-urlencoded'
|
|
13
|
+
},
|
|
14
|
+
data: encodedParams
|
|
15
|
+
};
|
|
16
|
+
axios
|
|
17
|
+
.request(options)
|
|
18
|
+
.then(function (response) {
|
|
19
|
+
console.log(response.data);
|
|
20
|
+
})["catch"](function (error) {
|
|
21
|
+
console.error(error);
|
|
22
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'GET',
|
|
5
|
+
url: 'https://httpbin.org/headers',
|
|
6
|
+
headers: { accept: 'application/json', 'x-foo': 'Bar', 'x-bar': 'Foo' }
|
|
7
|
+
};
|
|
8
|
+
axios
|
|
9
|
+
.request(options)
|
|
10
|
+
.then(function (response) {
|
|
11
|
+
console.log(response.data);
|
|
12
|
+
})["catch"](function (error) {
|
|
13
|
+
console.error(error);
|
|
14
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = { method: 'GET', url: 'http://httpbin.org/anything' };
|
|
4
|
+
axios
|
|
5
|
+
.request(options)
|
|
6
|
+
.then(function (response) {
|
|
7
|
+
console.log(response.data);
|
|
8
|
+
})["catch"](function (error) {
|
|
9
|
+
console.error(error);
|
|
10
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
url: 'https://httpbin.org/anything',
|
|
6
|
+
headers: { 'content-type': 'application/json' },
|
|
7
|
+
data: { foo: 'bar' }
|
|
8
|
+
};
|
|
9
|
+
axios
|
|
10
|
+
.request(options)
|
|
11
|
+
.then(function (response) {
|
|
12
|
+
console.log(response.data);
|
|
13
|
+
})["catch"](function (error) {
|
|
14
|
+
console.error(error);
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
url: 'https://httpbin.org/anything',
|
|
6
|
+
headers: { 'content-type': 'application/json' },
|
|
7
|
+
data: { foo: null }
|
|
8
|
+
};
|
|
9
|
+
axios
|
|
10
|
+
.request(options)
|
|
11
|
+
.then(function (response) {
|
|
12
|
+
console.log(response.data);
|
|
13
|
+
})["catch"](function (error) {
|
|
14
|
+
console.error(error);
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
url: 'https://httpbin.org/anything',
|
|
6
|
+
headers: { 'content-type': 'multipart/form-data; boundary=---011000010111000001101001' },
|
|
7
|
+
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="foo"; filename="hello.txt"\r\nContent-Type: text/plain\r\n\r\nHello World\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="bar"\r\n\r\nBonjour le monde\r\n-----011000010111000001101001--\r\n'
|
|
8
|
+
};
|
|
9
|
+
axios
|
|
10
|
+
.request(options)
|
|
11
|
+
.then(function (response) {
|
|
12
|
+
console.log(response.data);
|
|
13
|
+
})["catch"](function (error) {
|
|
14
|
+
console.error(error);
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
url: 'https://httpbin.org/anything',
|
|
6
|
+
headers: { 'content-type': 'multipart/form-data; boundary=---011000010111000001101001' },
|
|
7
|
+
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="foo"; filename="hello.txt"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--\r\n'
|
|
8
|
+
};
|
|
9
|
+
axios
|
|
10
|
+
.request(options)
|
|
11
|
+
.then(function (response) {
|
|
12
|
+
console.log(response.data);
|
|
13
|
+
})["catch"](function (error) {
|
|
14
|
+
console.error(error);
|
|
15
|
+
});
|