@readme/httpsnippet 5.1.0 → 5.1.1
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.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/application-json.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/cookies.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/custom-method.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/full.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/headers.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/http-insecure.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/jsonObj-multiline.js +2 -1
- 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.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data-no-params.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/nested.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/postdata-malformed.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/query-encoded.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/query.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/short.js +2 -1
- package/dist/targets/javascript/fetch/fixtures/text-plain.js +2 -1
- package/dist/targets/javascript/jquery/client.js +5 -5
- 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 +12 -12
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
var options = { method: 'POST', headers: { 'content-type': 'text/plain' }, body: 'Hello World' };
|
|
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); });
|
|
@@ -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.jquery = void 0;
|
|
18
18
|
var stringify_object_1 = __importDefault(require("stringify-object"));
|
|
19
19
|
var code_builder_1 = require("../../../helpers/code-builder");
|
|
@@ -23,7 +23,7 @@ exports.jquery = {
|
|
|
23
23
|
key: 'jquery',
|
|
24
24
|
title: 'jQuery',
|
|
25
25
|
link: 'http://api.jquery.com/jquery.ajax/',
|
|
26
|
-
description: 'Perform an asynchronous HTTP (Ajax) requests with jQuery'
|
|
26
|
+
description: 'Perform an asynchronous HTTP (Ajax) requests with jQuery',
|
|
27
27
|
},
|
|
28
28
|
convert: function (_a, options) {
|
|
29
29
|
var _b;
|
|
@@ -35,7 +35,7 @@ exports.jquery = {
|
|
|
35
35
|
crossDomain: true,
|
|
36
36
|
url: fullUrl,
|
|
37
37
|
method: method,
|
|
38
|
-
headers: allHeaders
|
|
38
|
+
headers: allHeaders,
|
|
39
39
|
};
|
|
40
40
|
switch (postData.mimeType) {
|
|
41
41
|
case 'application/x-www-form-urlencoded':
|
|
@@ -73,12 +73,12 @@ exports.jquery = {
|
|
|
73
73
|
settings.data = postData.text;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
var stringifiedSettings = (0, stringify_object_1
|
|
76
|
+
var stringifiedSettings = (0, stringify_object_1.default)(settings, { indent: opts.indent }).replace("'[form]'", 'form');
|
|
77
77
|
push("const settings = ".concat(stringifiedSettings, ";"));
|
|
78
78
|
blank();
|
|
79
79
|
push('$.ajax(settings).done(function (response) {');
|
|
80
80
|
push('console.log(response);', 1);
|
|
81
81
|
push('});');
|
|
82
82
|
return join();
|
|
83
|
-
}
|
|
83
|
+
},
|
|
84
84
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.javascript = void 0;
|
|
4
4
|
var client_1 = require("./axios/client");
|
|
5
5
|
var client_2 = require("./fetch/client");
|
|
@@ -10,12 +10,12 @@ exports.javascript = {
|
|
|
10
10
|
key: 'javascript',
|
|
11
11
|
title: 'JavaScript',
|
|
12
12
|
extname: '.js',
|
|
13
|
-
|
|
13
|
+
default: 'xhr',
|
|
14
14
|
},
|
|
15
15
|
clientsById: {
|
|
16
16
|
xhr: client_4.xhr,
|
|
17
17
|
axios: client_1.axios,
|
|
18
18
|
fetch: client_2.fetch,
|
|
19
|
-
jquery: client_3.jquery
|
|
20
|
-
}
|
|
19
|
+
jquery: client_3.jquery,
|
|
20
|
+
},
|
|
21
21
|
};
|
|
@@ -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.xhr = void 0;
|
|
18
18
|
var stringify_object_1 = __importDefault(require("stringify-object"));
|
|
19
19
|
var code_builder_1 = require("../../../helpers/code-builder");
|
|
@@ -23,7 +23,7 @@ exports.xhr = {
|
|
|
23
23
|
key: 'xhr',
|
|
24
24
|
title: 'XMLHttpRequest',
|
|
25
25
|
link: 'https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest',
|
|
26
|
-
description: 'W3C Standard API that provides scripted client functionality'
|
|
26
|
+
description: 'W3C Standard API that provides scripted client functionality',
|
|
27
27
|
},
|
|
28
28
|
convert: function (_a, options) {
|
|
29
29
|
var postData = _a.postData, allHeaders = _a.allHeaders, method = _a.method, fullUrl = _a.fullUrl;
|
|
@@ -31,8 +31,8 @@ exports.xhr = {
|
|
|
31
31
|
var _b = new code_builder_1.CodeBuilder({ indent: opts.indent }), blank = _b.blank, push = _b.push, join = _b.join;
|
|
32
32
|
switch (postData.mimeType) {
|
|
33
33
|
case 'application/json':
|
|
34
|
-
push("const data = JSON.stringify(".concat((0, stringify_object_1
|
|
35
|
-
indent: opts.indent
|
|
34
|
+
push("const data = JSON.stringify(".concat((0, stringify_object_1.default)(postData.jsonObj, {
|
|
35
|
+
indent: opts.indent,
|
|
36
36
|
}), ");"));
|
|
37
37
|
blank();
|
|
38
38
|
break;
|
|
@@ -77,5 +77,5 @@ exports.xhr = {
|
|
|
77
77
|
blank();
|
|
78
78
|
push('xhr.send(data);');
|
|
79
79
|
return join();
|
|
80
|
-
}
|
|
80
|
+
},
|
|
81
81
|
};
|
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
exports
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.okhttp = void 0;
|
|
15
15
|
var code_builder_1 = require("../../../helpers/code-builder");
|
|
16
16
|
exports.okhttp = {
|
|
@@ -18,7 +18,7 @@ exports.okhttp = {
|
|
|
18
18
|
key: 'okhttp',
|
|
19
19
|
title: 'OkHttp',
|
|
20
20
|
link: 'http://square.github.io/okhttp/',
|
|
21
|
-
description: 'An HTTP Request Client Library'
|
|
21
|
+
description: 'An HTTP Request Client Library',
|
|
22
22
|
},
|
|
23
23
|
convert: function (_a, options) {
|
|
24
24
|
var postData = _a.postData, fullUrl = _a.fullUrl, method = _a.method, allHeaders = _a.allHeaders;
|
|
@@ -66,5 +66,5 @@ exports.okhttp = {
|
|
|
66
66
|
blank();
|
|
67
67
|
push('val response = client.newCall(request).execute()');
|
|
68
68
|
return join();
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
70
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.kotlin = void 0;
|
|
4
4
|
var client_1 = require("./okhttp/client");
|
|
5
5
|
exports.kotlin = {
|
|
@@ -7,9 +7,9 @@ exports.kotlin = {
|
|
|
7
7
|
key: 'kotlin',
|
|
8
8
|
title: 'Kotlin',
|
|
9
9
|
extname: '.kt',
|
|
10
|
-
|
|
10
|
+
default: 'okhttp',
|
|
11
11
|
},
|
|
12
12
|
clientsById: {
|
|
13
|
-
okhttp: client_1.okhttp
|
|
14
|
-
}
|
|
13
|
+
okhttp: client_1.okhttp,
|
|
14
|
+
},
|
|
15
15
|
};
|
|
@@ -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.axios = void 0;
|
|
18
18
|
var stringify_object_1 = __importDefault(require("stringify-object"));
|
|
19
19
|
var code_builder_1 = require("../../../helpers/code-builder");
|
|
@@ -22,7 +22,7 @@ exports.axios = {
|
|
|
22
22
|
key: 'axios',
|
|
23
23
|
title: 'Axios',
|
|
24
24
|
link: 'https://github.com/axios/axios',
|
|
25
|
-
description: 'Promise based HTTP client for the browser and node.js'
|
|
25
|
+
description: 'Promise based HTTP client for the browser and node.js',
|
|
26
26
|
},
|
|
27
27
|
convert: function (_a, options) {
|
|
28
28
|
var method = _a.method, fullUrl = _a.fullUrl, allHeaders = _a.allHeaders, postData = _a.postData;
|
|
@@ -31,7 +31,7 @@ exports.axios = {
|
|
|
31
31
|
push("const axios = require('axios');");
|
|
32
32
|
var reqOpts = {
|
|
33
33
|
method: method,
|
|
34
|
-
url: fullUrl
|
|
34
|
+
url: fullUrl,
|
|
35
35
|
};
|
|
36
36
|
if (Object.keys(allHeaders).length) {
|
|
37
37
|
reqOpts.headers = allHeaders;
|
|
@@ -62,7 +62,7 @@ exports.axios = {
|
|
|
62
62
|
reqOpts.data = postData.text;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
var stringifiedOptions = (0, stringify_object_1
|
|
65
|
+
var stringifiedOptions = (0, stringify_object_1.default)(reqOpts, { indent: ' ', inlineCharacterLimit: 80 });
|
|
66
66
|
push("const options = ".concat(stringifiedOptions, ";"));
|
|
67
67
|
blank();
|
|
68
68
|
push('axios');
|
|
@@ -74,5 +74,5 @@ exports.axios = {
|
|
|
74
74
|
push('console.error(error);', 2);
|
|
75
75
|
push('});', 1);
|
|
76
76
|
return join();
|
|
77
|
-
}
|
|
77
|
+
},
|
|
78
78
|
};
|
|
@@ -8,12 +8,13 @@ var options = {
|
|
|
8
8
|
method: 'POST',
|
|
9
9
|
url: 'https://httpbin.org/anything',
|
|
10
10
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
11
|
-
data: encodedParams
|
|
11
|
+
data: encodedParams,
|
|
12
12
|
};
|
|
13
13
|
axios
|
|
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
|
});
|
|
@@ -11,12 +11,13 @@ var options = {
|
|
|
11
11
|
accept: 'application/json',
|
|
12
12
|
'content-type': 'application/x-www-form-urlencoded'
|
|
13
13
|
},
|
|
14
|
-
data: encodedParams
|
|
14
|
+
data: encodedParams,
|
|
15
15
|
};
|
|
16
16
|
axios
|
|
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
|
});
|
|
@@ -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,7 +23,7 @@ exports.fetch = {
|
|
|
23
23
|
key: 'fetch',
|
|
24
24
|
title: 'Fetch',
|
|
25
25
|
link: 'https://github.com/bitinn/node-fetch',
|
|
26
|
-
description: 'Simplified HTTP node-fetch client'
|
|
26
|
+
description: 'Simplified HTTP node-fetch client',
|
|
27
27
|
},
|
|
28
28
|
convert: function (_a, options) {
|
|
29
29
|
var _b;
|
|
@@ -34,7 +34,7 @@ exports.fetch = {
|
|
|
34
34
|
push("const fetch = require('node-fetch');");
|
|
35
35
|
var url = fullUrl;
|
|
36
36
|
var reqOpts = {
|
|
37
|
-
method: method
|
|
37
|
+
method: method,
|
|
38
38
|
};
|
|
39
39
|
if (Object.keys(headersObj).length) {
|
|
40
40
|
reqOpts.headers = headersObj;
|
|
@@ -107,7 +107,7 @@ exports.fetch = {
|
|
|
107
107
|
if (reqOpts.headers && !Object.keys(reqOpts.headers).length) {
|
|
108
108
|
delete reqOpts.headers;
|
|
109
109
|
}
|
|
110
|
-
var stringifiedOptions = (0, stringify_object_1
|
|
110
|
+
var stringifiedOptions = (0, stringify_object_1.default)(reqOpts, {
|
|
111
111
|
indent: ' ',
|
|
112
112
|
inlineCharacterLimit: 80,
|
|
113
113
|
// The Fetch API body only accepts string parameters, but stringified JSON can be difficult to
|
|
@@ -118,7 +118,7 @@ exports.fetch = {
|
|
|
118
118
|
return "JSON.stringify(".concat(originalResult, ")");
|
|
119
119
|
}
|
|
120
120
|
return originalResult;
|
|
121
|
-
}
|
|
121
|
+
},
|
|
122
122
|
});
|
|
123
123
|
push("const options = ".concat(stringifiedOptions, ";"));
|
|
124
124
|
blank();
|
|
@@ -136,5 +136,5 @@ exports.fetch = {
|
|
|
136
136
|
return join()
|
|
137
137
|
.replace(/'encodedParams'/, 'encodedParams')
|
|
138
138
|
.replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/, 'fs.createReadStream("$1")');
|
|
139
|
-
}
|
|
139
|
+
},
|
|
140
140
|
};
|
|
@@ -12,4 +12,5 @@ var options = {
|
|
|
12
12
|
};
|
|
13
13
|
fetch(url, options)
|
|
14
14
|
.then(function (res) { return res.json(); })
|
|
15
|
-
.then(function (json) { return console.log(json); })
|
|
15
|
+
.then(function (json) { return console.log(json); })
|
|
16
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -15,4 +15,5 @@ var options = {
|
|
|
15
15
|
};
|
|
16
16
|
fetch(url, options)
|
|
17
17
|
.then(function (res) { return res.json(); })
|
|
18
|
-
.then(function (json) { return console.log(json); })
|
|
18
|
+
.then(function (json) { return console.log(json); })
|
|
19
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/cookies';
|
|
|
4
4
|
var options = { method: 'GET', headers: { cookie: 'foo=bar; bar=baz' } };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/anything';
|
|
|
4
4
|
var options = { method: 'PROPFIND' };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -15,4 +15,5 @@ var options = {
|
|
|
15
15
|
};
|
|
16
16
|
fetch(url, options)
|
|
17
17
|
.then(function (res) { return res.json(); })
|
|
18
|
-
.then(function (json) { return console.log(json); })
|
|
18
|
+
.then(function (json) { return console.log(json); })
|
|
19
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -7,4 +7,5 @@ var options = {
|
|
|
7
7
|
};
|
|
8
8
|
fetch(url, options)
|
|
9
9
|
.then(function (res) { return res.json(); })
|
|
10
|
-
.then(function (json) { return console.log(json); })
|
|
10
|
+
.then(function (json) { return console.log(json); })
|
|
11
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'http://httpbin.org/anything';
|
|
|
4
4
|
var options = { method: 'GET' };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -8,4 +8,5 @@ var options = {
|
|
|
8
8
|
};
|
|
9
9
|
fetch(url, options)
|
|
10
10
|
.then(function (res) { return res.json(); })
|
|
11
|
-
.then(function (json) { return console.log(json); })
|
|
11
|
+
.then(function (json) { return console.log(json); })
|
|
12
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -8,4 +8,5 @@ var options = {
|
|
|
8
8
|
};
|
|
9
9
|
fetch(url, options)
|
|
10
10
|
.then(function (res) { return res.json(); })
|
|
11
|
-
.then(function (json) { return console.log(json); })
|
|
11
|
+
.then(function (json) { return console.log(json); })
|
|
12
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -10,4 +10,5 @@ var options = { method: 'POST' };
|
|
|
10
10
|
options.body = formData;
|
|
11
11
|
fetch(url, options)
|
|
12
12
|
.then(function (res) { return res.json(); })
|
|
13
|
-
.then(function (json) { return console.log(json); })
|
|
13
|
+
.then(function (json) { return console.log(json); })
|
|
14
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -9,4 +9,5 @@ var options = { method: 'POST' };
|
|
|
9
9
|
options.body = formData;
|
|
10
10
|
fetch(url, options)
|
|
11
11
|
.then(function (res) { return res.json(); })
|
|
12
|
-
.then(function (json) { return console.log(json); })
|
|
12
|
+
.then(function (json) { return console.log(json); })
|
|
13
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/anything';
|
|
|
4
4
|
var options = { method: 'POST', headers: { 'Content-Type': 'multipart/form-data' } };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -8,4 +8,5 @@ var options = { method: 'POST' };
|
|
|
8
8
|
options.body = formData;
|
|
9
9
|
fetch(url, options)
|
|
10
10
|
.then(function (res) { return res.json(); })
|
|
11
|
-
.then(function (json) { return console.log(json); })
|
|
11
|
+
.then(function (json) { return console.log(json); })
|
|
12
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/anything?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value
|
|
|
4
4
|
var options = { method: 'GET' };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/anything';
|
|
|
4
4
|
var options = { method: 'POST', headers: { 'content-type': 'application/json' } };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/anything?startTime=2019-06-13T19%3A08%3A25.455Z&e
|
|
|
4
4
|
var options = { method: 'GET' };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value';
|
|
|
4
4
|
var options = { method: 'GET' };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/anything';
|
|
|
4
4
|
var options = { method: 'GET' };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -4,4 +4,5 @@ var url = 'https://httpbin.org/anything';
|
|
|
4
4
|
var options = { method: 'POST', headers: { 'content-type': 'text/plain' }, body: 'Hello World' };
|
|
5
5
|
fetch(url, options)
|
|
6
6
|
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
7
|
+
.then(function (json) { return console.log(json); })
|
|
8
|
+
.catch(function (err) { return console.error('error:' + err); });
|