@readme/httpsnippet 5.0.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.
Files changed (143) hide show
  1. package/dist/helpers/code-builder.js +1 -1
  2. package/dist/helpers/form-data.js +2 -2
  3. package/dist/helpers/headers.js +1 -1
  4. package/dist/helpers/reducer.js +1 -1
  5. package/dist/helpers/shell.js +1 -1
  6. package/dist/helpers/utils.js +1 -1
  7. package/dist/index.js +14 -25
  8. package/dist/targets/c/libcurl/client.js +3 -3
  9. package/dist/targets/c/target.js +4 -4
  10. package/dist/targets/clojure/clj_http/client.js +10 -7
  11. package/dist/targets/clojure/target.js +4 -4
  12. package/dist/targets/csharp/httpclient/client.js +4 -4
  13. package/dist/targets/csharp/restsharp/client.js +3 -3
  14. package/dist/targets/csharp/target.js +4 -4
  15. package/dist/targets/go/native/client.js +3 -3
  16. package/dist/targets/go/target.js +4 -4
  17. package/dist/targets/http/http1.1/client.js +3 -3
  18. package/dist/targets/http/target.js +4 -4
  19. package/dist/targets/java/asynchttp/client.js +3 -3
  20. package/dist/targets/java/nethttp/client.js +3 -3
  21. package/dist/targets/java/okhttp/client.js +3 -3
  22. package/dist/targets/java/target.js +4 -4
  23. package/dist/targets/java/unirest/client.js +3 -3
  24. package/dist/targets/javascript/axios/client.js +6 -6
  25. package/dist/targets/javascript/axios/fixtures/application-form-encoded.js +5 -4
  26. package/dist/targets/javascript/axios/fixtures/application-json.js +4 -3
  27. package/dist/targets/javascript/axios/fixtures/cookies.js +4 -3
  28. package/dist/targets/javascript/axios/fixtures/custom-method.js +4 -3
  29. package/dist/targets/javascript/axios/fixtures/full.js +5 -4
  30. package/dist/targets/javascript/axios/fixtures/headers.js +4 -3
  31. package/dist/targets/javascript/axios/fixtures/http-insecure.js +4 -3
  32. package/dist/targets/javascript/axios/fixtures/jsonObj-multiline.js +4 -3
  33. package/dist/targets/javascript/axios/fixtures/jsonObj-null-value.js +4 -3
  34. package/dist/targets/javascript/axios/fixtures/multipart-data.js +4 -3
  35. package/dist/targets/javascript/axios/fixtures/multipart-file.js +4 -3
  36. package/dist/targets/javascript/axios/fixtures/multipart-form-data-no-params.js +4 -3
  37. package/dist/targets/javascript/axios/fixtures/multipart-form-data.js +4 -3
  38. package/dist/targets/javascript/axios/fixtures/nested.js +4 -3
  39. package/dist/targets/javascript/axios/fixtures/postdata-malformed.js +4 -3
  40. package/dist/targets/javascript/axios/fixtures/query-encoded.js +4 -3
  41. package/dist/targets/javascript/axios/fixtures/query.js +4 -3
  42. package/dist/targets/javascript/axios/fixtures/short.js +4 -3
  43. package/dist/targets/javascript/axios/fixtures/text-plain.js +4 -3
  44. package/dist/targets/javascript/fetch/client.js +6 -6
  45. package/dist/targets/javascript/fetch/fixtures/application-form-encoded.js +2 -1
  46. package/dist/targets/javascript/fetch/fixtures/application-json.js +2 -1
  47. package/dist/targets/javascript/fetch/fixtures/cookies.js +2 -1
  48. package/dist/targets/javascript/fetch/fixtures/custom-method.js +2 -1
  49. package/dist/targets/javascript/fetch/fixtures/full.js +2 -1
  50. package/dist/targets/javascript/fetch/fixtures/headers.js +2 -1
  51. package/dist/targets/javascript/fetch/fixtures/http-insecure.js +2 -1
  52. package/dist/targets/javascript/fetch/fixtures/jsonObj-multiline.js +2 -1
  53. package/dist/targets/javascript/fetch/fixtures/jsonObj-null-value.js +2 -1
  54. package/dist/targets/javascript/fetch/fixtures/multipart-data.js +2 -1
  55. package/dist/targets/javascript/fetch/fixtures/multipart-file.js +2 -1
  56. package/dist/targets/javascript/fetch/fixtures/multipart-form-data-no-params.js +2 -1
  57. package/dist/targets/javascript/fetch/fixtures/multipart-form-data.js +2 -1
  58. package/dist/targets/javascript/fetch/fixtures/nested.js +2 -1
  59. package/dist/targets/javascript/fetch/fixtures/postdata-malformed.js +2 -1
  60. package/dist/targets/javascript/fetch/fixtures/query-encoded.js +2 -1
  61. package/dist/targets/javascript/fetch/fixtures/query.js +2 -1
  62. package/dist/targets/javascript/fetch/fixtures/short.js +2 -1
  63. package/dist/targets/javascript/fetch/fixtures/text-plain.js +2 -1
  64. package/dist/targets/javascript/jquery/client.js +5 -5
  65. package/dist/targets/javascript/target.js +4 -4
  66. package/dist/targets/javascript/xhr/client.js +5 -5
  67. package/dist/targets/kotlin/okhttp/client.js +3 -3
  68. package/dist/targets/kotlin/target.js +4 -4
  69. package/dist/targets/node/axios/client.js +5 -5
  70. package/dist/targets/node/axios/fixtures/application-form-encoded.js +3 -2
  71. package/dist/targets/node/axios/fixtures/application-json.js +2 -1
  72. package/dist/targets/node/axios/fixtures/cookies.js +2 -1
  73. package/dist/targets/node/axios/fixtures/custom-method.js +2 -1
  74. package/dist/targets/node/axios/fixtures/full.js +3 -2
  75. package/dist/targets/node/axios/fixtures/headers.js +2 -1
  76. package/dist/targets/node/axios/fixtures/http-insecure.js +2 -1
  77. package/dist/targets/node/axios/fixtures/jsonObj-multiline.js +2 -1
  78. package/dist/targets/node/axios/fixtures/jsonObj-null-value.js +2 -1
  79. package/dist/targets/node/axios/fixtures/multipart-data.js +2 -1
  80. package/dist/targets/node/axios/fixtures/multipart-file.js +2 -1
  81. package/dist/targets/node/axios/fixtures/multipart-form-data-no-params.js +2 -1
  82. package/dist/targets/node/axios/fixtures/multipart-form-data.js +2 -1
  83. package/dist/targets/node/axios/fixtures/nested.js +2 -1
  84. package/dist/targets/node/axios/fixtures/postdata-malformed.js +2 -1
  85. package/dist/targets/node/axios/fixtures/query-encoded.js +2 -1
  86. package/dist/targets/node/axios/fixtures/query.js +2 -1
  87. package/dist/targets/node/axios/fixtures/short.js +2 -1
  88. package/dist/targets/node/axios/fixtures/text-plain.js +2 -1
  89. package/dist/targets/node/fetch/client.js +6 -6
  90. package/dist/targets/node/fetch/fixtures/application-form-encoded.js +2 -1
  91. package/dist/targets/node/fetch/fixtures/application-json.js +2 -1
  92. package/dist/targets/node/fetch/fixtures/cookies.js +2 -1
  93. package/dist/targets/node/fetch/fixtures/custom-method.js +2 -1
  94. package/dist/targets/node/fetch/fixtures/full.js +2 -1
  95. package/dist/targets/node/fetch/fixtures/headers.js +2 -1
  96. package/dist/targets/node/fetch/fixtures/http-insecure.js +2 -1
  97. package/dist/targets/node/fetch/fixtures/jsonObj-multiline.js +2 -1
  98. package/dist/targets/node/fetch/fixtures/jsonObj-null-value.js +2 -1
  99. package/dist/targets/node/fetch/fixtures/multipart-data.js +2 -1
  100. package/dist/targets/node/fetch/fixtures/multipart-file.js +2 -1
  101. package/dist/targets/node/fetch/fixtures/multipart-form-data-no-params.js +2 -1
  102. package/dist/targets/node/fetch/fixtures/multipart-form-data.js +2 -1
  103. package/dist/targets/node/fetch/fixtures/nested.js +2 -1
  104. package/dist/targets/node/fetch/fixtures/postdata-malformed.js +2 -1
  105. package/dist/targets/node/fetch/fixtures/query-encoded.js +2 -1
  106. package/dist/targets/node/fetch/fixtures/query.js +2 -1
  107. package/dist/targets/node/fetch/fixtures/short.js +2 -1
  108. package/dist/targets/node/fetch/fixtures/text-plain.js +2 -1
  109. package/dist/targets/node/native/client.js +10 -10
  110. package/dist/targets/node/request/client.js +7 -7
  111. package/dist/targets/node/target.js +5 -5
  112. package/dist/targets/node/unirest/client.js +10 -10
  113. package/dist/targets/objc/helpers.js +1 -1
  114. package/dist/targets/objc/nsurlsession/client.js +4 -4
  115. package/dist/targets/objc/target.js +4 -4
  116. package/dist/targets/ocaml/cohttp/client.js +3 -3
  117. package/dist/targets/ocaml/target.js +4 -4
  118. package/dist/targets/php/curl/client.js +12 -12
  119. package/dist/targets/php/guzzle/client.js +5 -5
  120. package/dist/targets/php/helpers.js +1 -1
  121. package/dist/targets/php/http1/client.js +3 -3
  122. package/dist/targets/php/http2/client.js +4 -4
  123. package/dist/targets/php/target.js +5 -5
  124. package/dist/targets/powershell/common.js +1 -1
  125. package/dist/targets/powershell/restmethod/client.js +3 -3
  126. package/dist/targets/powershell/target.js +4 -4
  127. package/dist/targets/powershell/webrequest/client.js +3 -3
  128. package/dist/targets/python/helpers.js +1 -1
  129. package/dist/targets/python/requests/client.js +3 -3
  130. package/dist/targets/python/target.js +5 -5
  131. package/dist/targets/r/httr/client.js +3 -3
  132. package/dist/targets/r/target.js +4 -4
  133. package/dist/targets/ruby/native/client.js +3 -3
  134. package/dist/targets/ruby/target.js +4 -4
  135. package/dist/targets/shell/curl/client.js +9 -6
  136. package/dist/targets/shell/httpie/client.js +4 -4
  137. package/dist/targets/shell/target.js +5 -5
  138. package/dist/targets/shell/wget/client.js +3 -3
  139. package/dist/targets/swift/helpers.js +1 -1
  140. package/dist/targets/swift/nsurlsession/client.js +4 -4
  141. package/dist/targets/swift/target.js +4 -4
  142. package/dist/targets/targets.js +4 -4
  143. package/package.json +12 -13
@@ -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); })["catch"](function (err) { return console.error(err); });
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.__esModule = true;
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["default"])(settings, { indent: opts.indent }).replace("'[form]'", 'form');
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.__esModule = true;
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
- "default": 'xhr'
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.__esModule = true;
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["default"])(postData.jsonObj, {
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.__esModule = true;
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.__esModule = true;
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
- "default": 'okhttp'
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.__esModule = true;
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["default"])(reqOpts, { indent: ' ', inlineCharacterLimit: 80 });
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
- })["catch"](function (error) {
17
+ })
18
+ .catch(function (error) {
18
19
  console.error(error);
19
20
  });
@@ -17,6 +17,7 @@ axios
17
17
  .request(options)
18
18
  .then(function (response) {
19
19
  console.log(response.data);
20
- })["catch"](function (error) {
20
+ })
21
+ .catch(function (error) {
21
22
  console.error(error);
22
23
  });
@@ -9,6 +9,7 @@ axios
9
9
  .request(options)
10
10
  .then(function (response) {
11
11
  console.log(response.data);
12
- })["catch"](function (error) {
12
+ })
13
+ .catch(function (error) {
13
14
  console.error(error);
14
15
  });
@@ -5,6 +5,7 @@ axios
5
5
  .request(options)
6
6
  .then(function (response) {
7
7
  console.log(response.data);
8
- })["catch"](function (error) {
8
+ })
9
+ .catch(function (error) {
9
10
  console.error(error);
10
11
  });
@@ -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
- })["catch"](function (error) {
20
+ })
21
+ .catch(function (error) {
21
22
  console.error(error);
22
23
  });
@@ -9,6 +9,7 @@ axios
9
9
  .request(options)
10
10
  .then(function (response) {
11
11
  console.log(response.data);
12
- })["catch"](function (error) {
12
+ })
13
+ .catch(function (error) {
13
14
  console.error(error);
14
15
  });
@@ -5,6 +5,7 @@ axios
5
5
  .request(options)
6
6
  .then(function (response) {
7
7
  console.log(response.data);
8
- })["catch"](function (error) {
8
+ })
9
+ .catch(function (error) {
9
10
  console.error(error);
10
11
  });
@@ -10,6 +10,7 @@ axios
10
10
  .request(options)
11
11
  .then(function (response) {
12
12
  console.log(response.data);
13
- })["catch"](function (error) {
13
+ })
14
+ .catch(function (error) {
14
15
  console.error(error);
15
16
  });
@@ -10,6 +10,7 @@ axios
10
10
  .request(options)
11
11
  .then(function (response) {
12
12
  console.log(response.data);
13
- })["catch"](function (error) {
13
+ })
14
+ .catch(function (error) {
14
15
  console.error(error);
15
16
  });
@@ -10,6 +10,7 @@ axios
10
10
  .request(options)
11
11
  .then(function (response) {
12
12
  console.log(response.data);
13
- })["catch"](function (error) {
13
+ })
14
+ .catch(function (error) {
14
15
  console.error(error);
15
16
  });
@@ -10,6 +10,7 @@ axios
10
10
  .request(options)
11
11
  .then(function (response) {
12
12
  console.log(response.data);
13
- })["catch"](function (error) {
13
+ })
14
+ .catch(function (error) {
14
15
  console.error(error);
15
16
  });
@@ -9,6 +9,7 @@ axios
9
9
  .request(options)
10
10
  .then(function (response) {
11
11
  console.log(response.data);
12
- })["catch"](function (error) {
12
+ })
13
+ .catch(function (error) {
13
14
  console.error(error);
14
15
  });
@@ -10,6 +10,7 @@ axios
10
10
  .request(options)
11
11
  .then(function (response) {
12
12
  console.log(response.data);
13
- })["catch"](function (error) {
13
+ })
14
+ .catch(function (error) {
14
15
  console.error(error);
15
16
  });
@@ -8,6 +8,7 @@ axios
8
8
  .request(options)
9
9
  .then(function (response) {
10
10
  console.log(response.data);
11
- })["catch"](function (error) {
11
+ })
12
+ .catch(function (error) {
12
13
  console.error(error);
13
14
  });
@@ -9,6 +9,7 @@ axios
9
9
  .request(options)
10
10
  .then(function (response) {
11
11
  console.log(response.data);
12
- })["catch"](function (error) {
12
+ })
13
+ .catch(function (error) {
13
14
  console.error(error);
14
15
  });
@@ -8,6 +8,7 @@ axios
8
8
  .request(options)
9
9
  .then(function (response) {
10
10
  console.log(response.data);
11
- })["catch"](function (error) {
11
+ })
12
+ .catch(function (error) {
12
13
  console.error(error);
13
14
  });
@@ -8,6 +8,7 @@ axios
8
8
  .request(options)
9
9
  .then(function (response) {
10
10
  console.log(response.data);
11
- })["catch"](function (error) {
11
+ })
12
+ .catch(function (error) {
12
13
  console.error(error);
13
14
  });
@@ -5,6 +5,7 @@ axios
5
5
  .request(options)
6
6
  .then(function (response) {
7
7
  console.log(response.data);
8
- })["catch"](function (error) {
8
+ })
9
+ .catch(function (error) {
9
10
  console.error(error);
10
11
  });
@@ -10,6 +10,7 @@ axios
10
10
  .request(options)
11
11
  .then(function (response) {
12
12
  console.log(response.data);
13
- })["catch"](function (error) {
13
+ })
14
+ .catch(function (error) {
14
15
  console.error(error);
15
16
  });
@@ -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.__esModule = true;
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["default"])(reqOpts, {
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
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); })["catch"](function (err) { return console.error('error:' + err); });
7
+ .then(function (json) { return console.log(json); })
8
+ .catch(function (err) { return console.error('error:' + err); });