@readme/httpsnippet 5.1.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/code-builder.js +1 -1
- package/dist/helpers/form-data.js +2 -2
- package/dist/helpers/headers.js +1 -1
- package/dist/helpers/reducer.js +1 -1
- package/dist/helpers/shell.js +1 -1
- package/dist/helpers/utils.js +1 -1
- package/dist/index.js +14 -25
- package/dist/targets/c/libcurl/client.js +3 -3
- package/dist/targets/c/target.js +4 -4
- package/dist/targets/clojure/clj_http/client.js +10 -7
- package/dist/targets/clojure/target.js +4 -4
- package/dist/targets/csharp/httpclient/client.js +4 -4
- package/dist/targets/csharp/restsharp/client.js +3 -3
- package/dist/targets/csharp/target.js +4 -4
- package/dist/targets/go/native/client.js +3 -3
- package/dist/targets/go/target.js +4 -4
- package/dist/targets/http/http1.1/client.js +3 -3
- package/dist/targets/http/target.js +4 -4
- package/dist/targets/java/asynchttp/client.js +3 -3
- package/dist/targets/java/nethttp/client.js +3 -3
- package/dist/targets/java/okhttp/client.js +3 -3
- package/dist/targets/java/target.js +4 -4
- package/dist/targets/java/unirest/client.js +3 -3
- package/dist/targets/javascript/axios/client.js +6 -6
- package/dist/targets/javascript/axios/fixtures/application-form-encoded.js +5 -4
- package/dist/targets/javascript/axios/fixtures/application-json.js +4 -3
- package/dist/targets/javascript/axios/fixtures/cookies.js +4 -3
- package/dist/targets/javascript/axios/fixtures/custom-method.js +4 -3
- package/dist/targets/javascript/axios/fixtures/full.js +5 -4
- package/dist/targets/javascript/axios/fixtures/headers.js +4 -3
- package/dist/targets/javascript/axios/fixtures/http-insecure.js +4 -3
- package/dist/targets/javascript/axios/fixtures/jsonObj-multiline.js +4 -3
- package/dist/targets/javascript/axios/fixtures/jsonObj-null-value.js +4 -3
- package/dist/targets/javascript/axios/fixtures/multipart-data.js +4 -3
- package/dist/targets/javascript/axios/fixtures/multipart-file.js +4 -3
- package/dist/targets/javascript/axios/fixtures/multipart-form-data-no-params.js +4 -3
- package/dist/targets/javascript/axios/fixtures/multipart-form-data.js +4 -3
- package/dist/targets/javascript/axios/fixtures/nested.js +4 -3
- package/dist/targets/javascript/axios/fixtures/postdata-malformed.js +4 -3
- package/dist/targets/javascript/axios/fixtures/query-encoded.js +4 -3
- package/dist/targets/javascript/axios/fixtures/query.js +4 -3
- package/dist/targets/javascript/axios/fixtures/short.js +4 -3
- package/dist/targets/javascript/axios/fixtures/text-plain.js +4 -3
- package/dist/targets/javascript/fetch/client.js +6 -6
- package/dist/targets/javascript/fetch/fixtures/application-form-encoded.d.ts +3 -3
- package/dist/targets/javascript/fetch/fixtures/application-form-encoded.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/application-json.d.ts +3 -3
- package/dist/targets/javascript/fetch/fixtures/application-json.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/cookies.d.ts +2 -2
- package/dist/targets/javascript/fetch/fixtures/cookies.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/custom-method.d.ts +1 -1
- package/dist/targets/javascript/fetch/fixtures/custom-method.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/full.d.ts +3 -3
- package/dist/targets/javascript/fetch/fixtures/full.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/headers.d.ts +2 -2
- package/dist/targets/javascript/fetch/fixtures/headers.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/http-insecure.d.ts +1 -1
- package/dist/targets/javascript/fetch/fixtures/http-insecure.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/jsonObj-multiline.d.ts +3 -3
- package/dist/targets/javascript/fetch/fixtures/jsonObj-multiline.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/jsonObj-null-value.d.ts +3 -3
- package/dist/targets/javascript/fetch/fixtures/jsonObj-null-value.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/multipart-data.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/multipart-file.d.ts +1 -1
- package/dist/targets/javascript/fetch/fixtures/multipart-file.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data-no-params.d.ts +2 -2
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data-no-params.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data.d.ts +1 -1
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/nested.d.ts +1 -1
- package/dist/targets/javascript/fetch/fixtures/nested.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/postdata-malformed.d.ts +2 -2
- package/dist/targets/javascript/fetch/fixtures/postdata-malformed.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/query-encoded.d.ts +1 -1
- package/dist/targets/javascript/fetch/fixtures/query-encoded.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/query.d.ts +1 -1
- package/dist/targets/javascript/fetch/fixtures/query.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/short.d.ts +1 -1
- package/dist/targets/javascript/fetch/fixtures/short.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/text-plain.d.ts +3 -3
- package/dist/targets/javascript/fetch/fixtures/text-plain.js +2 -1
- package/dist/targets/javascript/jquery/client.js +5 -5
- package/dist/targets/javascript/jquery/fixtures/application-form-encoded.d.ts +7 -7
- package/dist/targets/javascript/jquery/fixtures/application-json.d.ts +7 -7
- package/dist/targets/javascript/jquery/fixtures/cookies.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/custom-method.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/full.d.ts +6 -6
- package/dist/targets/javascript/jquery/fixtures/headers.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/http-insecure.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/jsonObj-multiline.d.ts +7 -7
- package/dist/targets/javascript/jquery/fixtures/jsonObj-null-value.d.ts +7 -7
- package/dist/targets/javascript/jquery/fixtures/multipart-data.d.ts +9 -9
- package/dist/targets/javascript/jquery/fixtures/multipart-file.d.ts +9 -9
- package/dist/targets/javascript/jquery/fixtures/multipart-form-data-no-params.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/multipart-form-data.d.ts +9 -9
- package/dist/targets/javascript/jquery/fixtures/nested.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/postdata-malformed.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/query-encoded.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/query.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/short.d.ts +5 -5
- package/dist/targets/javascript/jquery/fixtures/text-plain.d.ts +6 -6
- package/dist/targets/javascript/target.js +4 -4
- package/dist/targets/javascript/xhr/client.js +5 -5
- package/dist/targets/kotlin/okhttp/client.js +3 -3
- package/dist/targets/kotlin/target.js +4 -4
- package/dist/targets/node/axios/client.js +5 -5
- package/dist/targets/node/axios/fixtures/application-form-encoded.js +3 -2
- package/dist/targets/node/axios/fixtures/application-json.js +2 -1
- package/dist/targets/node/axios/fixtures/cookies.js +2 -1
- package/dist/targets/node/axios/fixtures/custom-method.js +2 -1
- package/dist/targets/node/axios/fixtures/full.js +3 -2
- package/dist/targets/node/axios/fixtures/headers.js +2 -1
- package/dist/targets/node/axios/fixtures/http-insecure.js +2 -1
- package/dist/targets/node/axios/fixtures/jsonObj-multiline.js +2 -1
- package/dist/targets/node/axios/fixtures/jsonObj-null-value.js +2 -1
- package/dist/targets/node/axios/fixtures/multipart-data.js +2 -1
- package/dist/targets/node/axios/fixtures/multipart-file.js +2 -1
- package/dist/targets/node/axios/fixtures/multipart-form-data-no-params.js +2 -1
- package/dist/targets/node/axios/fixtures/multipart-form-data.js +2 -1
- package/dist/targets/node/axios/fixtures/nested.js +2 -1
- package/dist/targets/node/axios/fixtures/postdata-malformed.js +2 -1
- package/dist/targets/node/axios/fixtures/query-encoded.js +2 -1
- package/dist/targets/node/axios/fixtures/query.js +2 -1
- package/dist/targets/node/axios/fixtures/short.js +2 -1
- package/dist/targets/node/axios/fixtures/text-plain.js +2 -1
- package/dist/targets/node/fetch/client.js +6 -6
- package/dist/targets/node/fetch/fixtures/application-form-encoded.js +2 -1
- package/dist/targets/node/fetch/fixtures/application-json.js +2 -1
- package/dist/targets/node/fetch/fixtures/cookies.js +2 -1
- package/dist/targets/node/fetch/fixtures/custom-method.js +2 -1
- package/dist/targets/node/fetch/fixtures/full.js +2 -1
- package/dist/targets/node/fetch/fixtures/headers.js +2 -1
- package/dist/targets/node/fetch/fixtures/http-insecure.js +2 -1
- package/dist/targets/node/fetch/fixtures/jsonObj-multiline.js +2 -1
- package/dist/targets/node/fetch/fixtures/jsonObj-null-value.js +2 -1
- package/dist/targets/node/fetch/fixtures/multipart-data.js +2 -1
- package/dist/targets/node/fetch/fixtures/multipart-file.js +2 -1
- package/dist/targets/node/fetch/fixtures/multipart-form-data-no-params.js +2 -1
- package/dist/targets/node/fetch/fixtures/multipart-form-data.js +2 -1
- package/dist/targets/node/fetch/fixtures/nested.js +2 -1
- package/dist/targets/node/fetch/fixtures/postdata-malformed.js +2 -1
- package/dist/targets/node/fetch/fixtures/query-encoded.js +2 -1
- package/dist/targets/node/fetch/fixtures/query.js +2 -1
- package/dist/targets/node/fetch/fixtures/short.js +2 -1
- package/dist/targets/node/fetch/fixtures/text-plain.js +2 -1
- package/dist/targets/node/native/client.js +10 -10
- package/dist/targets/node/request/client.js +7 -7
- package/dist/targets/node/target.js +5 -5
- package/dist/targets/node/unirest/client.js +10 -10
- package/dist/targets/objc/helpers.js +1 -1
- package/dist/targets/objc/nsurlsession/client.js +4 -4
- package/dist/targets/objc/target.js +4 -4
- package/dist/targets/ocaml/cohttp/client.js +3 -3
- package/dist/targets/ocaml/target.js +4 -4
- package/dist/targets/php/curl/client.js +12 -12
- package/dist/targets/php/guzzle/client.js +5 -5
- package/dist/targets/php/helpers.js +1 -1
- package/dist/targets/php/http1/client.js +3 -3
- package/dist/targets/php/http2/client.js +4 -4
- package/dist/targets/php/target.js +5 -5
- package/dist/targets/powershell/common.js +1 -1
- package/dist/targets/powershell/restmethod/client.js +3 -3
- package/dist/targets/powershell/target.js +4 -4
- package/dist/targets/powershell/webrequest/client.js +3 -3
- package/dist/targets/python/helpers.js +1 -1
- package/dist/targets/python/requests/client.js +3 -3
- package/dist/targets/python/target.js +5 -5
- package/dist/targets/r/httr/client.js +3 -3
- package/dist/targets/r/target.js +4 -4
- package/dist/targets/ruby/native/client.js +3 -3
- package/dist/targets/ruby/target.js +4 -4
- package/dist/targets/shell/curl/client.js +4 -4
- package/dist/targets/shell/httpie/client.js +4 -4
- package/dist/targets/shell/target.js +5 -5
- package/dist/targets/shell/wget/client.js +3 -3
- package/dist/targets/swift/helpers.js +1 -1
- package/dist/targets/swift/nsurlsession/client.js +4 -4
- package/dist/targets/swift/target.js +4 -4
- package/dist/targets/targets.js +4 -4
- package/package.json +14 -14
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var encodedParams = new URLSearchParams();
|
|
8
8
|
encodedParams.set('foo', 'bar');
|
|
@@ -11,12 +11,13 @@ var options = {
|
|
|
11
11
|
method: 'POST',
|
|
12
12
|
url: 'https://httpbin.org/anything',
|
|
13
13
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
14
|
-
data: encodedParams
|
|
14
|
+
data: encodedParams,
|
|
15
15
|
};
|
|
16
|
-
axios_1
|
|
16
|
+
axios_1.default
|
|
17
17
|
.request(options)
|
|
18
18
|
.then(function (response) {
|
|
19
19
|
console.log(response.data);
|
|
20
|
-
})
|
|
20
|
+
})
|
|
21
|
+
.catch(function (error) {
|
|
21
22
|
console.error(error);
|
|
22
23
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'POST',
|
|
@@ -17,10 +17,11 @@ var options = {
|
|
|
17
17
|
boolean: false
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
axios_1
|
|
20
|
+
axios_1.default
|
|
21
21
|
.request(options)
|
|
22
22
|
.then(function (response) {
|
|
23
23
|
console.log(response.data);
|
|
24
|
-
})
|
|
24
|
+
})
|
|
25
|
+
.catch(function (error) {
|
|
25
26
|
console.error(error);
|
|
26
27
|
});
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'GET',
|
|
9
9
|
url: 'https://httpbin.org/cookies',
|
|
10
10
|
headers: { cookie: 'foo=bar; bar=baz' }
|
|
11
11
|
};
|
|
12
|
-
axios_1
|
|
12
|
+
axios_1.default
|
|
13
13
|
.request(options)
|
|
14
14
|
.then(function (response) {
|
|
15
15
|
console.log(response.data);
|
|
16
|
-
})
|
|
16
|
+
})
|
|
17
|
+
.catch(function (error) {
|
|
17
18
|
console.error(error);
|
|
18
19
|
});
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = { method: 'PROPFIND', url: 'https://httpbin.org/anything' };
|
|
8
|
-
axios_1
|
|
8
|
+
axios_1.default
|
|
9
9
|
.request(options)
|
|
10
10
|
.then(function (response) {
|
|
11
11
|
console.log(response.data);
|
|
12
|
-
})
|
|
12
|
+
})
|
|
13
|
+
.catch(function (error) {
|
|
13
14
|
console.error(error);
|
|
14
15
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var encodedParams = new URLSearchParams();
|
|
8
8
|
encodedParams.set('foo', 'bar');
|
|
@@ -15,12 +15,13 @@ var options = {
|
|
|
15
15
|
accept: 'application/json',
|
|
16
16
|
'content-type': 'application/x-www-form-urlencoded'
|
|
17
17
|
},
|
|
18
|
-
data: encodedParams
|
|
18
|
+
data: encodedParams,
|
|
19
19
|
};
|
|
20
|
-
axios_1
|
|
20
|
+
axios_1.default
|
|
21
21
|
.request(options)
|
|
22
22
|
.then(function (response) {
|
|
23
23
|
console.log(response.data);
|
|
24
|
-
})
|
|
24
|
+
})
|
|
25
|
+
.catch(function (error) {
|
|
25
26
|
console.error(error);
|
|
26
27
|
});
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'GET',
|
|
9
9
|
url: 'https://httpbin.org/headers',
|
|
10
10
|
headers: { accept: 'application/json', 'x-foo': 'Bar', 'x-bar': 'Foo' }
|
|
11
11
|
};
|
|
12
|
-
axios_1
|
|
12
|
+
axios_1.default
|
|
13
13
|
.request(options)
|
|
14
14
|
.then(function (response) {
|
|
15
15
|
console.log(response.data);
|
|
16
|
-
})
|
|
16
|
+
})
|
|
17
|
+
.catch(function (error) {
|
|
17
18
|
console.error(error);
|
|
18
19
|
});
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = { method: 'GET', url: 'http://httpbin.org/anything' };
|
|
8
|
-
axios_1
|
|
8
|
+
axios_1.default
|
|
9
9
|
.request(options)
|
|
10
10
|
.then(function (response) {
|
|
11
11
|
console.log(response.data);
|
|
12
|
-
})
|
|
12
|
+
})
|
|
13
|
+
.catch(function (error) {
|
|
13
14
|
console.error(error);
|
|
14
15
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'POST',
|
|
@@ -10,10 +10,11 @@ var options = {
|
|
|
10
10
|
headers: { 'content-type': 'application/json' },
|
|
11
11
|
data: { foo: 'bar' }
|
|
12
12
|
};
|
|
13
|
-
axios_1
|
|
13
|
+
axios_1.default
|
|
14
14
|
.request(options)
|
|
15
15
|
.then(function (response) {
|
|
16
16
|
console.log(response.data);
|
|
17
|
-
})
|
|
17
|
+
})
|
|
18
|
+
.catch(function (error) {
|
|
18
19
|
console.error(error);
|
|
19
20
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'POST',
|
|
@@ -10,10 +10,11 @@ var options = {
|
|
|
10
10
|
headers: { 'content-type': 'application/json' },
|
|
11
11
|
data: { foo: null }
|
|
12
12
|
};
|
|
13
|
-
axios_1
|
|
13
|
+
axios_1.default
|
|
14
14
|
.request(options)
|
|
15
15
|
.then(function (response) {
|
|
16
16
|
console.log(response.data);
|
|
17
|
-
})
|
|
17
|
+
})
|
|
18
|
+
.catch(function (error) {
|
|
18
19
|
console.error(error);
|
|
19
20
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var form = new FormData();
|
|
8
8
|
form.append('foo', 'Hello World');
|
|
@@ -13,10 +13,11 @@ var options = {
|
|
|
13
13
|
headers: { 'content-type': 'multipart/form-data; boundary=---011000010111000001101001' },
|
|
14
14
|
data: '[form]'
|
|
15
15
|
};
|
|
16
|
-
axios_1
|
|
16
|
+
axios_1.default
|
|
17
17
|
.request(options)
|
|
18
18
|
.then(function (response) {
|
|
19
19
|
console.log(response.data);
|
|
20
|
-
})
|
|
20
|
+
})
|
|
21
|
+
.catch(function (error) {
|
|
21
22
|
console.error(error);
|
|
22
23
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var form = new FormData();
|
|
8
8
|
form.append('foo', 'src/fixtures/files/hello.txt');
|
|
@@ -12,10 +12,11 @@ var options = {
|
|
|
12
12
|
headers: { 'content-type': 'multipart/form-data; boundary=---011000010111000001101001' },
|
|
13
13
|
data: '[form]'
|
|
14
14
|
};
|
|
15
|
-
axios_1
|
|
15
|
+
axios_1.default
|
|
16
16
|
.request(options)
|
|
17
17
|
.then(function (response) {
|
|
18
18
|
console.log(response.data);
|
|
19
|
-
})
|
|
19
|
+
})
|
|
20
|
+
.catch(function (error) {
|
|
20
21
|
console.error(error);
|
|
21
22
|
});
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'POST',
|
|
9
9
|
url: 'https://httpbin.org/anything',
|
|
10
10
|
headers: { 'Content-Type': 'multipart/form-data' }
|
|
11
11
|
};
|
|
12
|
-
axios_1
|
|
12
|
+
axios_1.default
|
|
13
13
|
.request(options)
|
|
14
14
|
.then(function (response) {
|
|
15
15
|
console.log(response.data);
|
|
16
|
-
})
|
|
16
|
+
})
|
|
17
|
+
.catch(function (error) {
|
|
17
18
|
console.error(error);
|
|
18
19
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var form = new FormData();
|
|
8
8
|
form.append('foo', 'bar');
|
|
@@ -12,10 +12,11 @@ var options = {
|
|
|
12
12
|
headers: { 'Content-Type': 'multipart/form-data; boundary=---011000010111000001101001' },
|
|
13
13
|
data: '[form]'
|
|
14
14
|
};
|
|
15
|
-
axios_1
|
|
15
|
+
axios_1.default
|
|
16
16
|
.request(options)
|
|
17
17
|
.then(function (response) {
|
|
18
18
|
console.log(response.data);
|
|
19
|
-
})
|
|
19
|
+
})
|
|
20
|
+
.catch(function (error) {
|
|
20
21
|
console.error(error);
|
|
21
22
|
});
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'GET',
|
|
9
9
|
url: 'https://httpbin.org/anything',
|
|
10
10
|
params: { 'foo[bar]': 'baz,zap', fiz: 'buz', key: 'value' }
|
|
11
11
|
};
|
|
12
|
-
axios_1
|
|
12
|
+
axios_1.default
|
|
13
13
|
.request(options)
|
|
14
14
|
.then(function (response) {
|
|
15
15
|
console.log(response.data);
|
|
16
|
-
})
|
|
16
|
+
})
|
|
17
|
+
.catch(function (error) {
|
|
17
18
|
console.error(error);
|
|
18
19
|
});
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'POST',
|
|
9
9
|
url: 'https://httpbin.org/anything',
|
|
10
10
|
headers: { 'content-type': 'application/json' }
|
|
11
11
|
};
|
|
12
|
-
axios_1
|
|
12
|
+
axios_1.default
|
|
13
13
|
.request(options)
|
|
14
14
|
.then(function (response) {
|
|
15
15
|
console.log(response.data);
|
|
16
|
-
})
|
|
16
|
+
})
|
|
17
|
+
.catch(function (error) {
|
|
17
18
|
console.error(error);
|
|
18
19
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'GET',
|
|
@@ -12,10 +12,11 @@ var options = {
|
|
|
12
12
|
endTime: '2015-09-15T14%3A00%3A12-04%3A00'
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
axios_1
|
|
15
|
+
axios_1.default
|
|
16
16
|
.request(options)
|
|
17
17
|
.then(function (response) {
|
|
18
18
|
console.log(response.data);
|
|
19
|
-
})
|
|
19
|
+
})
|
|
20
|
+
.catch(function (error) {
|
|
20
21
|
console.error(error);
|
|
21
22
|
});
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'GET',
|
|
9
9
|
url: 'https://httpbin.org/anything',
|
|
10
10
|
params: { foo: ['bar', 'baz'], baz: 'abc', key: 'value' }
|
|
11
11
|
};
|
|
12
|
-
axios_1
|
|
12
|
+
axios_1.default
|
|
13
13
|
.request(options)
|
|
14
14
|
.then(function (response) {
|
|
15
15
|
console.log(response.data);
|
|
16
|
-
})
|
|
16
|
+
})
|
|
17
|
+
.catch(function (error) {
|
|
17
18
|
console.error(error);
|
|
18
19
|
});
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = { method: 'GET', url: 'https://httpbin.org/anything' };
|
|
8
|
-
axios_1
|
|
8
|
+
axios_1.default
|
|
9
9
|
.request(options)
|
|
10
10
|
.then(function (response) {
|
|
11
11
|
console.log(response.data);
|
|
12
|
-
})
|
|
12
|
+
})
|
|
13
|
+
.catch(function (error) {
|
|
13
14
|
console.error(error);
|
|
14
15
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var axios_1 = __importDefault(require("axios"));
|
|
7
7
|
var options = {
|
|
8
8
|
method: 'POST',
|
|
@@ -10,10 +10,11 @@ var options = {
|
|
|
10
10
|
headers: { 'content-type': 'text/plain' },
|
|
11
11
|
data: 'Hello World'
|
|
12
12
|
};
|
|
13
|
-
axios_1
|
|
13
|
+
axios_1.default
|
|
14
14
|
.request(options)
|
|
15
15
|
.then(function (response) {
|
|
16
16
|
console.log(response.data);
|
|
17
|
-
})
|
|
17
|
+
})
|
|
18
|
+
.catch(function (error) {
|
|
18
19
|
console.error(error);
|
|
19
20
|
});
|
|
@@ -13,7 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.fetch = void 0;
|
|
18
18
|
var stringify_object_1 = __importDefault(require("stringify-object"));
|
|
19
19
|
var code_builder_1 = require("../../../helpers/code-builder");
|
|
@@ -23,14 +23,14 @@ exports.fetch = {
|
|
|
23
23
|
key: 'fetch',
|
|
24
24
|
title: 'fetch',
|
|
25
25
|
link: 'https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch',
|
|
26
|
-
description: 'Perform asynchronous HTTP requests with the Fetch API'
|
|
26
|
+
description: 'Perform asynchronous HTTP requests with the Fetch API',
|
|
27
27
|
},
|
|
28
28
|
convert: function (_a, inputOpts) {
|
|
29
29
|
var method = _a.method, allHeaders = _a.allHeaders, postData = _a.postData, fullUrl = _a.fullUrl;
|
|
30
30
|
var opts = __assign({ indent: ' ', credentials: null }, inputOpts);
|
|
31
31
|
var _b = new code_builder_1.CodeBuilder({ indent: opts.indent }), blank = _b.blank, join = _b.join, push = _b.push;
|
|
32
32
|
var options = {
|
|
33
|
-
method: method
|
|
33
|
+
method: method,
|
|
34
34
|
};
|
|
35
35
|
if (Object.keys(allHeaders).length) {
|
|
36
36
|
options.headers = allHeaders;
|
|
@@ -74,7 +74,7 @@ exports.fetch = {
|
|
|
74
74
|
if (options.headers && !Object.keys(options.headers).length) {
|
|
75
75
|
delete options.headers;
|
|
76
76
|
}
|
|
77
|
-
push("const options = ".concat((0, stringify_object_1
|
|
77
|
+
push("const options = ".concat((0, stringify_object_1.default)(options, {
|
|
78
78
|
indent: opts.indent,
|
|
79
79
|
inlineCharacterLimit: 80,
|
|
80
80
|
// The Fetch API body only accepts string parameters, but stringified JSON can be difficult
|
|
@@ -90,7 +90,7 @@ exports.fetch = {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
return originalResult;
|
|
93
|
-
}
|
|
93
|
+
},
|
|
94
94
|
}), ";"));
|
|
95
95
|
blank();
|
|
96
96
|
if (postData.params && postData.mimeType === 'multipart/form-data') {
|
|
@@ -102,5 +102,5 @@ exports.fetch = {
|
|
|
102
102
|
push('.then(response => console.log(response))', 1);
|
|
103
103
|
push('.catch(err => console.error(err));', 1);
|
|
104
104
|
return join();
|
|
105
|
-
}
|
|
105
|
+
},
|
|
106
106
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
declare namespace options {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
let method: string;
|
|
4
|
+
let headers: {
|
|
5
5
|
'content-type': string;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
let body: import("url").URLSearchParams;
|
|
8
8
|
}
|
|
@@ -6,4 +6,5 @@ var options = {
|
|
|
6
6
|
};
|
|
7
7
|
fetch('https://httpbin.org/anything', options)
|
|
8
8
|
.then(function (response) { return response.json(); })
|
|
9
|
-
.then(function (response) { return console.log(response); })
|
|
9
|
+
.then(function (response) { return console.log(response); })
|
|
10
|
+
.catch(function (err) { return console.error(err); });
|
|
@@ -13,4 +13,5 @@ var options = {
|
|
|
13
13
|
};
|
|
14
14
|
fetch('https://httpbin.org/anything', options)
|
|
15
15
|
.then(function (response) { return response.json(); })
|
|
16
|
-
.then(function (response) { return console.log(response); })
|
|
16
|
+
.then(function (response) { return console.log(response); })
|
|
17
|
+
.catch(function (err) { return console.error(err); });
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
var options = { method: 'GET', headers: { cookie: 'foo=bar; bar=baz' } };
|
|
3
3
|
fetch('https://httpbin.org/cookies', options)
|
|
4
4
|
.then(function (response) { return response.json(); })
|
|
5
|
-
.then(function (response) { return console.log(response); })
|
|
5
|
+
.then(function (response) { return console.log(response); })
|
|
6
|
+
.catch(function (err) { return console.error(err); });
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
var options = { method: 'PROPFIND' };
|
|
3
3
|
fetch('https://httpbin.org/anything', options)
|
|
4
4
|
.then(function (response) { return response.json(); })
|
|
5
|
-
.then(function (response) { return console.log(response); })
|
|
5
|
+
.then(function (response) { return console.log(response); })
|
|
6
|
+
.catch(function (err) { return console.error(err); });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
declare namespace options {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
let method: string;
|
|
4
|
+
let headers: {
|
|
5
5
|
cookie: string;
|
|
6
6
|
accept: string;
|
|
7
7
|
'content-type': string;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
let body: import("url").URLSearchParams;
|
|
10
10
|
}
|
|
@@ -10,4 +10,5 @@ var options = {
|
|
|
10
10
|
};
|
|
11
11
|
fetch('https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value', options)
|
|
12
12
|
.then(function (response) { return response.json(); })
|
|
13
|
-
.then(function (response) { return console.log(response); })
|
|
13
|
+
.then(function (response) { return console.log(response); })
|
|
14
|
+
.catch(function (err) { return console.error(err); });
|
|
@@ -5,4 +5,5 @@ var options = {
|
|
|
5
5
|
};
|
|
6
6
|
fetch('https://httpbin.org/headers', options)
|
|
7
7
|
.then(function (response) { return response.json(); })
|
|
8
|
-
.then(function (response) { return console.log(response); })
|
|
8
|
+
.then(function (response) { return console.log(response); })
|
|
9
|
+
.catch(function (err) { return console.error(err); });
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
var options = { method: 'GET' };
|
|
3
3
|
fetch('http://httpbin.org/anything', options)
|
|
4
4
|
.then(function (response) { return response.json(); })
|
|
5
|
-
.then(function (response) { return console.log(response); })
|
|
5
|
+
.then(function (response) { return console.log(response); })
|
|
6
|
+
.catch(function (err) { return console.error(err); });
|
|
@@ -6,4 +6,5 @@ var options = {
|
|
|
6
6
|
};
|
|
7
7
|
fetch('https://httpbin.org/anything', options)
|
|
8
8
|
.then(function (response) { return response.json(); })
|
|
9
|
-
.then(function (response) { return console.log(response); })
|
|
9
|
+
.then(function (response) { return console.log(response); })
|
|
10
|
+
.catch(function (err) { return console.error(err); });
|