@readme/httpsnippet 6.2.1 → 7.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/chunk-XPUGYZ4Y.mjs +3485 -0
- package/dist/chunk-XPUGYZ4Y.mjs.map +1 -0
- package/dist/index-acc66e3d.d.ts +167 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -95
- package/dist/index.js +3777 -261
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +299 -0
- package/dist/index.mjs.map +1 -0
- package/dist/targets/targets.d.mts +4 -0
- package/dist/targets/targets.d.ts +4 -53
- package/dist/targets/targets.js +3476 -113
- package/dist/targets/targets.js.map +1 -0
- package/dist/targets/targets.mjs +3 -0
- package/dist/targets/targets.mjs.map +1 -0
- package/package.json +30 -14
- package/dist/helpers/code-builder.d.ts +0 -49
- package/dist/helpers/code-builder.js +0 -91
- package/dist/helpers/escape.d.ts +0 -46
- package/dist/helpers/escape.js +0 -101
- package/dist/helpers/form-data.d.ts +0 -30
- package/dist/helpers/form-data.js +0 -157
- package/dist/helpers/headers.d.ts +0 -18
- package/dist/helpers/headers.js +0 -33
- package/dist/helpers/reducer.d.ts +0 -5
- package/dist/helpers/reducer.js +0 -19
- package/dist/helpers/shell.d.ts +0 -6
- package/dist/helpers/shell.js +0 -20
- package/dist/helpers/utils.d.ts +0 -6
- package/dist/helpers/utils.js +0 -21
- package/dist/targets/c/libcurl/client.d.ts +0 -2
- package/dist/targets/c/libcurl/client.js +0 -45
- package/dist/targets/c/target.d.ts +0 -2
- package/dist/targets/c/target.js +0 -16
- package/dist/targets/clojure/clj_http/client.d.ts +0 -11
- package/dist/targets/clojure/clj_http/client.js +0 -178
- package/dist/targets/clojure/target.d.ts +0 -2
- package/dist/targets/clojure/target.js +0 -15
- package/dist/targets/csharp/httpclient/client.d.ts +0 -2
- package/dist/targets/csharp/httpclient/client.js +0 -163
- package/dist/targets/csharp/restsharp/client.d.ts +0 -2
- package/dist/targets/csharp/restsharp/client.js +0 -92
- package/dist/targets/csharp/target.d.ts +0 -2
- package/dist/targets/csharp/target.js +0 -18
- package/dist/targets/go/native/client.d.ts +0 -17
- package/dist/targets/go/native/client.js +0 -103
- package/dist/targets/go/target.d.ts +0 -2
- package/dist/targets/go/target.js +0 -16
- package/dist/targets/http/http1.1/client.d.ts +0 -23
- package/dist/targets/http/http1.1/client.js +0 -69
- package/dist/targets/http/target.d.ts +0 -2
- package/dist/targets/http/target.js +0 -15
- package/dist/targets/java/asynchttp/client.d.ts +0 -11
- package/dist/targets/java/asynchttp/client.js +0 -45
- package/dist/targets/java/nethttp/client.d.ts +0 -14
- package/dist/targets/java/nethttp/client.js +0 -44
- package/dist/targets/java/okhttp/client.d.ts +0 -11
- package/dist/targets/java/okhttp/client.js +0 -71
- package/dist/targets/java/target.d.ts +0 -2
- package/dist/targets/java/target.js +0 -21
- package/dist/targets/java/unirest/client.d.ts +0 -11
- package/dist/targets/java/unirest/client.js +0 -45
- package/dist/targets/javascript/axios/client.d.ts +0 -11
- package/dist/targets/javascript/axios/client.js +0 -92
- package/dist/targets/javascript/axios/fixtures/application-form-encoded.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/application-form-encoded.js +0 -23
- package/dist/targets/javascript/axios/fixtures/application-json.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/application-json.js +0 -27
- package/dist/targets/javascript/axios/fixtures/cookies.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/cookies.js +0 -19
- package/dist/targets/javascript/axios/fixtures/custom-method.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/custom-method.js +0 -15
- package/dist/targets/javascript/axios/fixtures/full.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/full.js +0 -27
- package/dist/targets/javascript/axios/fixtures/headers.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/headers.js +0 -24
- package/dist/targets/javascript/axios/fixtures/http-insecure.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/http-insecure.js +0 -15
- package/dist/targets/javascript/axios/fixtures/jsonObj-multiline.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/jsonObj-multiline.js +0 -20
- package/dist/targets/javascript/axios/fixtures/jsonObj-null-value.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/jsonObj-null-value.js +0 -20
- package/dist/targets/javascript/axios/fixtures/multipart-data.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/multipart-data.js +0 -23
- package/dist/targets/javascript/axios/fixtures/multipart-file.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/multipart-file.js +0 -22
- package/dist/targets/javascript/axios/fixtures/multipart-form-data-no-params.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/multipart-form-data-no-params.js +0 -19
- package/dist/targets/javascript/axios/fixtures/multipart-form-data.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/multipart-form-data.js +0 -22
- package/dist/targets/javascript/axios/fixtures/nested.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/nested.js +0 -19
- package/dist/targets/javascript/axios/fixtures/postdata-malformed.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/postdata-malformed.js +0 -19
- package/dist/targets/javascript/axios/fixtures/query-encoded.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/query-encoded.js +0 -22
- package/dist/targets/javascript/axios/fixtures/query.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/query.js +0 -19
- package/dist/targets/javascript/axios/fixtures/short.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/short.js +0 -15
- package/dist/targets/javascript/axios/fixtures/text-plain.d.ts +0 -1
- package/dist/targets/javascript/axios/fixtures/text-plain.js +0 -20
- package/dist/targets/javascript/fetch/client.d.ts +0 -15
- package/dist/targets/javascript/fetch/client.js +0 -106
- package/dist/targets/javascript/fetch/fixtures/application-form-encoded.d.ts +0 -8
- package/dist/targets/javascript/fetch/fixtures/application-form-encoded.js +0 -10
- package/dist/targets/javascript/fetch/fixtures/application-json.d.ts +0 -7
- package/dist/targets/javascript/fetch/fixtures/application-json.js +0 -17
- package/dist/targets/javascript/fetch/fixtures/cookies.d.ts +0 -6
- package/dist/targets/javascript/fetch/fixtures/cookies.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/custom-method.d.ts +0 -3
- package/dist/targets/javascript/fetch/fixtures/custom-method.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/full.d.ts +0 -10
- package/dist/targets/javascript/fetch/fixtures/full.js +0 -14
- package/dist/targets/javascript/fetch/fixtures/headers.d.ts +0 -9
- package/dist/targets/javascript/fetch/fixtures/headers.js +0 -14
- package/dist/targets/javascript/fetch/fixtures/http-insecure.d.ts +0 -3
- package/dist/targets/javascript/fetch/fixtures/http-insecure.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/jsonObj-multiline.d.ts +0 -7
- package/dist/targets/javascript/fetch/fixtures/jsonObj-multiline.js +0 -10
- package/dist/targets/javascript/fetch/fixtures/jsonObj-null-value.d.ts +0 -7
- package/dist/targets/javascript/fetch/fixtures/jsonObj-null-value.js +0 -10
- package/dist/targets/javascript/fetch/fixtures/multipart-data.d.ts +0 -4
- package/dist/targets/javascript/fetch/fixtures/multipart-data.js +0 -10
- package/dist/targets/javascript/fetch/fixtures/multipart-file.d.ts +0 -4
- package/dist/targets/javascript/fetch/fixtures/multipart-file.js +0 -9
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data-no-params.d.ts +0 -6
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data-no-params.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data.d.ts +0 -4
- package/dist/targets/javascript/fetch/fixtures/multipart-form-data.js +0 -9
- package/dist/targets/javascript/fetch/fixtures/nested.d.ts +0 -3
- package/dist/targets/javascript/fetch/fixtures/nested.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/postdata-malformed.d.ts +0 -6
- package/dist/targets/javascript/fetch/fixtures/postdata-malformed.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/query-encoded.d.ts +0 -3
- package/dist/targets/javascript/fetch/fixtures/query-encoded.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/query.d.ts +0 -3
- package/dist/targets/javascript/fetch/fixtures/query.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/short.d.ts +0 -3
- package/dist/targets/javascript/fetch/fixtures/short.js +0 -6
- package/dist/targets/javascript/fetch/fixtures/text-plain.d.ts +0 -7
- package/dist/targets/javascript/fetch/fixtures/text-plain.js +0 -6
- package/dist/targets/javascript/jquery/client.d.ts +0 -11
- package/dist/targets/javascript/jquery/client.js +0 -84
- package/dist/targets/javascript/jquery/fixtures/application-form-encoded.d.ts +0 -13
- package/dist/targets/javascript/jquery/fixtures/application-form-encoded.js +0 -17
- package/dist/targets/javascript/jquery/fixtures/application-json.d.ts +0 -11
- package/dist/targets/javascript/jquery/fixtures/application-json.js +0 -15
- package/dist/targets/javascript/jquery/fixtures/cookies.d.ts +0 -9
- package/dist/targets/javascript/jquery/fixtures/cookies.js +0 -13
- package/dist/targets/javascript/jquery/fixtures/custom-method.d.ts +0 -7
- package/dist/targets/javascript/jquery/fixtures/custom-method.js +0 -11
- package/dist/targets/javascript/jquery/fixtures/full.d.ts +0 -14
- package/dist/targets/javascript/jquery/fixtures/full.js +0 -18
- package/dist/targets/javascript/jquery/fixtures/headers.d.ts +0 -12
- package/dist/targets/javascript/jquery/fixtures/headers.js +0 -16
- package/dist/targets/javascript/jquery/fixtures/http-insecure.d.ts +0 -7
- package/dist/targets/javascript/jquery/fixtures/http-insecure.js +0 -11
- package/dist/targets/javascript/jquery/fixtures/jsonObj-multiline.d.ts +0 -11
- package/dist/targets/javascript/jquery/fixtures/jsonObj-multiline.js +0 -15
- package/dist/targets/javascript/jquery/fixtures/jsonObj-null-value.d.ts +0 -11
- package/dist/targets/javascript/jquery/fixtures/jsonObj-null-value.js +0 -15
- package/dist/targets/javascript/jquery/fixtures/multipart-data.d.ts +0 -12
- package/dist/targets/javascript/jquery/fixtures/multipart-data.js +0 -18
- package/dist/targets/javascript/jquery/fixtures/multipart-file.d.ts +0 -12
- package/dist/targets/javascript/jquery/fixtures/multipart-file.js +0 -17
- package/dist/targets/javascript/jquery/fixtures/multipart-form-data-no-params.d.ts +0 -9
- package/dist/targets/javascript/jquery/fixtures/multipart-form-data-no-params.js +0 -13
- package/dist/targets/javascript/jquery/fixtures/multipart-form-data.d.ts +0 -12
- package/dist/targets/javascript/jquery/fixtures/multipart-form-data.js +0 -17
- package/dist/targets/javascript/jquery/fixtures/nested.d.ts +0 -7
- package/dist/targets/javascript/jquery/fixtures/nested.js +0 -11
- package/dist/targets/javascript/jquery/fixtures/postdata-malformed.d.ts +0 -9
- package/dist/targets/javascript/jquery/fixtures/postdata-malformed.js +0 -13
- package/dist/targets/javascript/jquery/fixtures/query-encoded.d.ts +0 -7
- package/dist/targets/javascript/jquery/fixtures/query-encoded.js +0 -11
- package/dist/targets/javascript/jquery/fixtures/query.d.ts +0 -7
- package/dist/targets/javascript/jquery/fixtures/query.js +0 -11
- package/dist/targets/javascript/jquery/fixtures/short.d.ts +0 -7
- package/dist/targets/javascript/jquery/fixtures/short.js +0 -11
- package/dist/targets/javascript/jquery/fixtures/text-plain.d.ts +0 -10
- package/dist/targets/javascript/jquery/fixtures/text-plain.js +0 -14
- package/dist/targets/javascript/target.d.ts +0 -2
- package/dist/targets/javascript/target.js +0 -21
- package/dist/targets/javascript/xhr/client.d.ts +0 -14
- package/dist/targets/javascript/xhr/client.js +0 -83
- package/dist/targets/javascript/xhr/fixtures/application-form-encoded.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/application-form-encoded.js +0 -12
- package/dist/targets/javascript/xhr/fixtures/application-json.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/application-json.js +0 -31
- package/dist/targets/javascript/xhr/fixtures/cookies.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/cookies.js +0 -12
- package/dist/targets/javascript/xhr/fixtures/cors.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/cors.js +0 -10
- package/dist/targets/javascript/xhr/fixtures/custom-method.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/custom-method.js +0 -11
- package/dist/targets/javascript/xhr/fixtures/full.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/full.js +0 -14
- package/dist/targets/javascript/xhr/fixtures/headers.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/headers.js +0 -15
- package/dist/targets/javascript/xhr/fixtures/http-insecure.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/http-insecure.js +0 -11
- package/dist/targets/javascript/xhr/fixtures/jsonObj-multiline.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/jsonObj-multiline.js +0 -14
- package/dist/targets/javascript/xhr/fixtures/jsonObj-null-value.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/jsonObj-null-value.js +0 -14
- package/dist/targets/javascript/xhr/fixtures/multipart-data.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/multipart-data.js +0 -13
- package/dist/targets/javascript/xhr/fixtures/multipart-file.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/multipart-file.js +0 -12
- package/dist/targets/javascript/xhr/fixtures/multipart-form-data-no-params.d.ts +0 -1
- package/dist/targets/javascript/xhr/fixtures/multipart-form-data-no-params.js +0 -11
- package/dist/targets/javascript/xhr/fixtures/multipart-form-data.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/multipart-form-data.js +0 -12
- package/dist/targets/javascript/xhr/fixtures/nested.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/nested.js +0 -11
- package/dist/targets/javascript/xhr/fixtures/postdata-malformed.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/postdata-malformed.js +0 -12
- package/dist/targets/javascript/xhr/fixtures/query-encoded.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/query-encoded.js +0 -11
- package/dist/targets/javascript/xhr/fixtures/query.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/query.js +0 -11
- package/dist/targets/javascript/xhr/fixtures/short.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/short.js +0 -11
- package/dist/targets/javascript/xhr/fixtures/text-plain.d.ts +0 -2
- package/dist/targets/javascript/xhr/fixtures/text-plain.js +0 -12
- package/dist/targets/json/native/client.d.ts +0 -2
- package/dist/targets/json/native/client.js +0 -56
- package/dist/targets/json/target.d.ts +0 -2
- package/dist/targets/json/target.js +0 -15
- package/dist/targets/kotlin/okhttp/client.d.ts +0 -11
- package/dist/targets/kotlin/okhttp/client.js +0 -71
- package/dist/targets/kotlin/target.d.ts +0 -2
- package/dist/targets/kotlin/target.js +0 -15
- package/dist/targets/node/axios/client.d.ts +0 -11
- package/dist/targets/node/axios/client.js +0 -78
- package/dist/targets/node/axios/fixtures/application-form-encoded.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/application-form-encoded.js +0 -20
- package/dist/targets/node/axios/fixtures/application-json.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/application-json.js +0 -23
- package/dist/targets/node/axios/fixtures/cookies.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/cookies.js +0 -15
- package/dist/targets/node/axios/fixtures/custom-method.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/custom-method.js +0 -11
- package/dist/targets/node/axios/fixtures/full.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/full.js +0 -23
- package/dist/targets/node/axios/fixtures/headers.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/headers.js +0 -20
- package/dist/targets/node/axios/fixtures/http-insecure.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/http-insecure.js +0 -11
- package/dist/targets/node/axios/fixtures/jsonObj-multiline.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/jsonObj-multiline.js +0 -16
- package/dist/targets/node/axios/fixtures/jsonObj-null-value.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/jsonObj-null-value.js +0 -16
- package/dist/targets/node/axios/fixtures/multipart-data.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/multipart-data.js +0 -16
- package/dist/targets/node/axios/fixtures/multipart-file.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/multipart-file.js +0 -16
- package/dist/targets/node/axios/fixtures/multipart-form-data-no-params.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/multipart-form-data-no-params.js +0 -15
- package/dist/targets/node/axios/fixtures/multipart-form-data.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/multipart-form-data.js +0 -16
- package/dist/targets/node/axios/fixtures/nested.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/nested.js +0 -14
- package/dist/targets/node/axios/fixtures/postdata-malformed.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/postdata-malformed.js +0 -15
- package/dist/targets/node/axios/fixtures/query-encoded.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/query-encoded.js +0 -14
- package/dist/targets/node/axios/fixtures/query.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/query.js +0 -14
- package/dist/targets/node/axios/fixtures/short.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/short.js +0 -11
- package/dist/targets/node/axios/fixtures/text-plain.d.ts +0 -1
- package/dist/targets/node/axios/fixtures/text-plain.js +0 -16
- package/dist/targets/node/fetch/client.d.ts +0 -11
- package/dist/targets/node/fetch/client.js +0 -140
- package/dist/targets/node/fetch/fixtures/application-form-encoded.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/application-form-encoded.js +0 -16
- package/dist/targets/node/fetch/fixtures/application-json.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/application-json.js +0 -19
- package/dist/targets/node/fetch/fixtures/cookies.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/cookies.js +0 -8
- package/dist/targets/node/fetch/fixtures/custom-method.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/custom-method.js +0 -8
- package/dist/targets/node/fetch/fixtures/full.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/full.js +0 -19
- package/dist/targets/node/fetch/fixtures/headers.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/headers.js +0 -16
- package/dist/targets/node/fetch/fixtures/http-insecure.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/http-insecure.js +0 -8
- package/dist/targets/node/fetch/fixtures/jsonObj-multiline.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/jsonObj-multiline.js +0 -12
- package/dist/targets/node/fetch/fixtures/jsonObj-null-value.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/jsonObj-null-value.js +0 -12
- package/dist/targets/node/fetch/fixtures/multipart-data.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/multipart-data.js +0 -14
- package/dist/targets/node/fetch/fixtures/multipart-file.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/multipart-file.js +0 -13
- package/dist/targets/node/fetch/fixtures/multipart-form-data-no-params.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/multipart-form-data-no-params.js +0 -8
- package/dist/targets/node/fetch/fixtures/multipart-form-data.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/multipart-form-data.js +0 -12
- package/dist/targets/node/fetch/fixtures/nested.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/nested.js +0 -8
- package/dist/targets/node/fetch/fixtures/postdata-malformed.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/postdata-malformed.js +0 -8
- package/dist/targets/node/fetch/fixtures/query-encoded.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/query-encoded.js +0 -8
- package/dist/targets/node/fetch/fixtures/query.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/query.js +0 -8
- package/dist/targets/node/fetch/fixtures/short.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/short.js +0 -8
- package/dist/targets/node/fetch/fixtures/text-plain.d.ts +0 -1
- package/dist/targets/node/fetch/fixtures/text-plain.js +0 -8
- package/dist/targets/node/native/client.d.ts +0 -11
- package/dist/targets/node/native/client.js +0 -72
- package/dist/targets/node/native/fixtures/application-form-encoded.d.ts +0 -1
- package/dist/targets/node/native/fixtures/application-form-encoded.js +0 -24
- package/dist/targets/node/native/fixtures/application-json.d.ts +0 -1
- package/dist/targets/node/native/fixtures/application-json.js +0 -30
- package/dist/targets/node/native/fixtures/cookies.d.ts +0 -1
- package/dist/targets/node/native/fixtures/cookies.js +0 -22
- package/dist/targets/node/native/fixtures/custom-method.d.ts +0 -1
- package/dist/targets/node/native/fixtures/custom-method.js +0 -20
- package/dist/targets/node/native/fixtures/full.d.ts +0 -1
- package/dist/targets/node/native/fixtures/full.js +0 -26
- package/dist/targets/node/native/fixtures/headers.d.ts +0 -1
- package/dist/targets/node/native/fixtures/headers.js +0 -25
- package/dist/targets/node/native/fixtures/http-insecure.d.ts +0 -1
- package/dist/targets/node/native/fixtures/http-insecure.js +0 -20
- package/dist/targets/node/native/fixtures/jsonObj-multiline.d.ts +0 -1
- package/dist/targets/node/native/fixtures/jsonObj-multiline.js +0 -23
- package/dist/targets/node/native/fixtures/jsonObj-null-value.d.ts +0 -1
- package/dist/targets/node/native/fixtures/jsonObj-null-value.js +0 -23
- package/dist/targets/node/native/fixtures/multipart-data.d.ts +0 -1
- package/dist/targets/node/native/fixtures/multipart-data.js +0 -23
- package/dist/targets/node/native/fixtures/multipart-file.d.ts +0 -1
- package/dist/targets/node/native/fixtures/multipart-file.js +0 -23
- package/dist/targets/node/native/fixtures/multipart-form-data-no-params.d.ts +0 -1
- package/dist/targets/node/native/fixtures/multipart-form-data-no-params.js +0 -22
- package/dist/targets/node/native/fixtures/multipart-form-data.d.ts +0 -1
- package/dist/targets/node/native/fixtures/multipart-form-data.js +0 -23
- package/dist/targets/node/native/fixtures/nested.d.ts +0 -1
- package/dist/targets/node/native/fixtures/nested.js +0 -20
- package/dist/targets/node/native/fixtures/postdata-malformed.d.ts +0 -1
- package/dist/targets/node/native/fixtures/postdata-malformed.js +0 -22
- package/dist/targets/node/native/fixtures/query-encoded.d.ts +0 -1
- package/dist/targets/node/native/fixtures/query-encoded.js +0 -20
- package/dist/targets/node/native/fixtures/query.d.ts +0 -1
- package/dist/targets/node/native/fixtures/query.js +0 -20
- package/dist/targets/node/native/fixtures/short.d.ts +0 -1
- package/dist/targets/node/native/fixtures/short.js +0 -20
- package/dist/targets/node/native/fixtures/text-plain.d.ts +0 -1
- package/dist/targets/node/native/fixtures/text-plain.js +0 -23
- package/dist/targets/node/request/client.d.ts +0 -11
- package/dist/targets/node/request/client.js +0 -107
- package/dist/targets/node/request/fixtures/application-form-encoded.d.ts +0 -1
- package/dist/targets/node/request/fixtures/application-form-encoded.js +0 -13
- package/dist/targets/node/request/fixtures/application-json.d.ts +0 -1
- package/dist/targets/node/request/fixtures/application-json.js +0 -21
- package/dist/targets/node/request/fixtures/cookies.d.ts +0 -1
- package/dist/targets/node/request/fixtures/cookies.js +0 -11
- package/dist/targets/node/request/fixtures/custom-method.d.ts +0 -1
- package/dist/targets/node/request/fixtures/custom-method.js +0 -8
- package/dist/targets/node/request/fixtures/full.d.ts +0 -1
- package/dist/targets/node/request/fixtures/full.js +0 -20
- package/dist/targets/node/request/fixtures/headers.d.ts +0 -1
- package/dist/targets/node/request/fixtures/headers.js +0 -17
- package/dist/targets/node/request/fixtures/http-insecure.d.ts +0 -1
- package/dist/targets/node/request/fixtures/http-insecure.js +0 -8
- package/dist/targets/node/request/fixtures/jsonObj-multiline.d.ts +0 -1
- package/dist/targets/node/request/fixtures/jsonObj-multiline.js +0 -14
- package/dist/targets/node/request/fixtures/jsonObj-null-value.d.ts +0 -1
- package/dist/targets/node/request/fixtures/jsonObj-null-value.js +0 -14
- package/dist/targets/node/request/fixtures/multipart-data.d.ts +0 -1
- package/dist/targets/node/request/fixtures/multipart-data.js +0 -20
- package/dist/targets/node/request/fixtures/multipart-file.d.ts +0 -1
- package/dist/targets/node/request/fixtures/multipart-file.js +0 -19
- package/dist/targets/node/request/fixtures/multipart-form-data-no-params.d.ts +0 -1
- package/dist/targets/node/request/fixtures/multipart-form-data-no-params.js +0 -12
- package/dist/targets/node/request/fixtures/multipart-form-data.d.ts +0 -1
- package/dist/targets/node/request/fixtures/multipart-form-data.js +0 -13
- package/dist/targets/node/request/fixtures/nested.d.ts +0 -1
- package/dist/targets/node/request/fixtures/nested.js +0 -11
- package/dist/targets/node/request/fixtures/postdata-malformed.d.ts +0 -1
- package/dist/targets/node/request/fixtures/postdata-malformed.js +0 -12
- package/dist/targets/node/request/fixtures/query-encoded.d.ts +0 -1
- package/dist/targets/node/request/fixtures/query-encoded.js +0 -11
- package/dist/targets/node/request/fixtures/query.d.ts +0 -1
- package/dist/targets/node/request/fixtures/query.js +0 -11
- package/dist/targets/node/request/fixtures/short.d.ts +0 -1
- package/dist/targets/node/request/fixtures/short.js +0 -8
- package/dist/targets/node/request/fixtures/text-plain.d.ts +0 -1
- package/dist/targets/node/request/fixtures/text-plain.js +0 -13
- package/dist/targets/node/target.d.ts +0 -2
- package/dist/targets/node/target.js +0 -24
- package/dist/targets/node/unirest/client.d.ts +0 -11
- package/dist/targets/node/unirest/client.js +0 -110
- package/dist/targets/node/unirest/fixtures/application-form-encoded.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/application-form-encoded.js +0 -15
- package/dist/targets/node/unirest/fixtures/application-json.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/application-json.js +0 -32
- package/dist/targets/node/unirest/fixtures/cookies.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/cookies.js +0 -12
- package/dist/targets/node/unirest/fixtures/custom-method.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/custom-method.js +0 -8
- package/dist/targets/node/unirest/fixtures/full.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/full.js +0 -27
- package/dist/targets/node/unirest/fixtures/headers.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/headers.js +0 -14
- package/dist/targets/node/unirest/fixtures/http-insecure.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/http-insecure.js +0 -8
- package/dist/targets/node/unirest/fixtures/jsonObj-multiline.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/jsonObj-multiline.js +0 -15
- package/dist/targets/node/unirest/fixtures/jsonObj-null-value.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/jsonObj-null-value.js +0 -15
- package/dist/targets/node/unirest/fixtures/multipart-data.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/multipart-data.js +0 -20
- package/dist/targets/node/unirest/fixtures/multipart-file.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/multipart-file.js +0 -18
- package/dist/targets/node/unirest/fixtures/multipart-form-data-no-params.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/multipart-form-data-no-params.js +0 -11
- package/dist/targets/node/unirest/fixtures/multipart-form-data.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/multipart-form-data.js +0 -16
- package/dist/targets/node/unirest/fixtures/nested.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/nested.js +0 -13
- package/dist/targets/node/unirest/fixtures/postdata-malformed.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/postdata-malformed.js +0 -11
- package/dist/targets/node/unirest/fixtures/query-encoded.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/query-encoded.js +0 -12
- package/dist/targets/node/unirest/fixtures/query.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/query.js +0 -16
- package/dist/targets/node/unirest/fixtures/short.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/short.js +0 -8
- package/dist/targets/node/unirest/fixtures/text-plain.d.ts +0 -1
- package/dist/targets/node/unirest/fixtures/text-plain.js +0 -12
- package/dist/targets/objc/helpers.d.ts +0 -26
- package/dist/targets/objc/helpers.js +0 -59
- package/dist/targets/objc/nsurlsession/client.d.ts +0 -15
- package/dist/targets/objc/nsurlsession/client.js +0 -143
- package/dist/targets/objc/target.d.ts +0 -2
- package/dist/targets/objc/target.js +0 -15
- package/dist/targets/ocaml/cohttp/client.d.ts +0 -11
- package/dist/targets/ocaml/cohttp/client.js +0 -64
- package/dist/targets/ocaml/target.d.ts +0 -2
- package/dist/targets/ocaml/target.js +0 -15
- package/dist/targets/php/curl/client.d.ts +0 -19
- package/dist/targets/php/curl/client.js +0 -122
- package/dist/targets/php/guzzle/client.d.ts +0 -17
- package/dist/targets/php/guzzle/client.js +0 -119
- package/dist/targets/php/helpers.d.ts +0 -2
- package/dist/targets/php/helpers.js +0 -66
- package/dist/targets/php/http1/client.d.ts +0 -16
- package/dist/targets/php/http1/client.js +0 -76
- package/dist/targets/php/http2/client.d.ts +0 -16
- package/dist/targets/php/http2/client.js +0 -115
- package/dist/targets/php/target.d.ts +0 -2
- package/dist/targets/php/target.js +0 -22
- package/dist/targets/powershell/common.d.ts +0 -3
- package/dist/targets/powershell/common.js +0 -50
- package/dist/targets/powershell/restmethod/client.d.ts +0 -2
- package/dist/targets/powershell/restmethod/client.js +0 -13
- package/dist/targets/powershell/target.d.ts +0 -2
- package/dist/targets/powershell/target.js +0 -17
- package/dist/targets/powershell/webrequest/client.d.ts +0 -2
- package/dist/targets/powershell/webrequest/client.js +0 -13
- package/dist/targets/python/helpers.d.ts +0 -8
- package/dist/targets/python/helpers.js +0 -64
- package/dist/targets/python/requests/client.d.ts +0 -14
- package/dist/targets/python/requests/client.js +0 -162
- package/dist/targets/python/target.d.ts +0 -2
- package/dist/targets/python/target.js +0 -16
- package/dist/targets/r/httr/client.d.ts +0 -11
- package/dist/targets/r/httr/client.js +0 -130
- package/dist/targets/r/target.d.ts +0 -2
- package/dist/targets/r/target.js +0 -15
- package/dist/targets/ruby/native/client.d.ts +0 -2
- package/dist/targets/ruby/native/client.js +0 -67
- package/dist/targets/ruby/target.d.ts +0 -2
- package/dist/targets/ruby/target.js +0 -15
- package/dist/targets/shell/curl/client.d.ts +0 -19
- package/dist/targets/shell/curl/client.js +0 -166
- package/dist/targets/shell/httpie/client.d.ts +0 -24
- package/dist/targets/shell/httpie/client.js +0 -102
- package/dist/targets/shell/target.d.ts +0 -2
- package/dist/targets/shell/target.js +0 -20
- package/dist/targets/shell/wget/client.d.ts +0 -16
- package/dist/targets/shell/wget/client.js +0 -46
- package/dist/targets/swift/helpers.d.ts +0 -16
- package/dist/targets/swift/helpers.js +0 -80
- package/dist/targets/swift/nsurlsession/client.d.ts +0 -15
- package/dist/targets/swift/nsurlsession/client.js +0 -148
- package/dist/targets/swift/target.d.ts +0 -2
- package/dist/targets/swift/target.js +0 -15
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var axios = require('axios');
|
|
3
|
-
var options = {
|
|
4
|
-
method: 'GET',
|
|
5
|
-
url: 'https://httpbin.org/anything?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value'
|
|
6
|
-
};
|
|
7
|
-
axios
|
|
8
|
-
.request(options)
|
|
9
|
-
.then(function (response) {
|
|
10
|
-
console.log(response.data);
|
|
11
|
-
})
|
|
12
|
-
.catch(function (error) {
|
|
13
|
-
console.error(error);
|
|
14
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var axios = require('axios');
|
|
3
|
-
var options = {
|
|
4
|
-
method: 'POST',
|
|
5
|
-
url: 'https://httpbin.org/anything',
|
|
6
|
-
headers: { 'content-type': 'application/json' }
|
|
7
|
-
};
|
|
8
|
-
axios
|
|
9
|
-
.request(options)
|
|
10
|
-
.then(function (response) {
|
|
11
|
-
console.log(response.data);
|
|
12
|
-
})
|
|
13
|
-
.catch(function (error) {
|
|
14
|
-
console.error(error);
|
|
15
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var axios = require('axios');
|
|
3
|
-
var options = {
|
|
4
|
-
method: 'GET',
|
|
5
|
-
url: 'https://httpbin.org/anything?startTime=2019-06-13T19%3A08%3A25.455Z&endTime=2015-09-15T14%3A00%3A12-04%3A00'
|
|
6
|
-
};
|
|
7
|
-
axios
|
|
8
|
-
.request(options)
|
|
9
|
-
.then(function (response) {
|
|
10
|
-
console.log(response.data);
|
|
11
|
-
})
|
|
12
|
-
.catch(function (error) {
|
|
13
|
-
console.error(error);
|
|
14
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var axios = require('axios');
|
|
3
|
-
var options = {
|
|
4
|
-
method: 'GET',
|
|
5
|
-
url: 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value'
|
|
6
|
-
};
|
|
7
|
-
axios
|
|
8
|
-
.request(options)
|
|
9
|
-
.then(function (response) {
|
|
10
|
-
console.log(response.data);
|
|
11
|
-
})
|
|
12
|
-
.catch(function (error) {
|
|
13
|
-
console.error(error);
|
|
14
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var axios = require('axios');
|
|
3
|
-
var options = { method: 'GET', url: 'https://httpbin.org/anything' };
|
|
4
|
-
axios
|
|
5
|
-
.request(options)
|
|
6
|
-
.then(function (response) {
|
|
7
|
-
console.log(response.data);
|
|
8
|
-
})
|
|
9
|
-
.catch(function (error) {
|
|
10
|
-
console.error(error);
|
|
11
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var axios = require('axios');
|
|
3
|
-
var options = {
|
|
4
|
-
method: 'POST',
|
|
5
|
-
url: 'https://httpbin.org/anything',
|
|
6
|
-
headers: { 'content-type': 'text/plain' },
|
|
7
|
-
data: 'Hello World'
|
|
8
|
-
};
|
|
9
|
-
axios
|
|
10
|
-
.request(options)
|
|
11
|
-
.then(function (response) {
|
|
12
|
-
console.log(response.data);
|
|
13
|
-
})
|
|
14
|
-
.catch(function (error) {
|
|
15
|
-
console.error(error);
|
|
16
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description
|
|
3
|
-
* HTTP code snippet generator for Node.js using node-fetch.
|
|
4
|
-
*
|
|
5
|
-
* @author
|
|
6
|
-
* @hirenoble
|
|
7
|
-
*
|
|
8
|
-
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
9
|
-
*/
|
|
10
|
-
import type { Client } from '../../targets';
|
|
11
|
-
export declare const fetch: Client;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.fetch = void 0;
|
|
18
|
-
var stringify_object_1 = __importDefault(require("stringify-object"));
|
|
19
|
-
var code_builder_1 = require("../../../helpers/code-builder");
|
|
20
|
-
var headers_1 = require("../../../helpers/headers");
|
|
21
|
-
exports.fetch = {
|
|
22
|
-
info: {
|
|
23
|
-
key: 'fetch',
|
|
24
|
-
title: 'Fetch',
|
|
25
|
-
link: 'https://github.com/bitinn/node-fetch',
|
|
26
|
-
description: 'Simplified HTTP node-fetch client',
|
|
27
|
-
},
|
|
28
|
-
convert: function (_a, options) {
|
|
29
|
-
var _b;
|
|
30
|
-
var method = _a.method, fullUrl = _a.fullUrl, postData = _a.postData, headersObj = _a.headersObj, cookies = _a.cookies;
|
|
31
|
-
var opts = __assign({ indent: ' ' }, options);
|
|
32
|
-
var includeFS = false;
|
|
33
|
-
var _c = new code_builder_1.CodeBuilder({ indent: opts.indent }), blank = _c.blank, push = _c.push, join = _c.join, unshift = _c.unshift;
|
|
34
|
-
push("const fetch = require('node-fetch');");
|
|
35
|
-
var url = fullUrl;
|
|
36
|
-
var reqOpts = {
|
|
37
|
-
method: method,
|
|
38
|
-
};
|
|
39
|
-
if (Object.keys(headersObj).length) {
|
|
40
|
-
reqOpts.headers = headersObj;
|
|
41
|
-
}
|
|
42
|
-
switch (postData.mimeType) {
|
|
43
|
-
case 'application/x-www-form-urlencoded':
|
|
44
|
-
unshift("const { URLSearchParams } = require('url');");
|
|
45
|
-
push('const encodedParams = new URLSearchParams();');
|
|
46
|
-
blank();
|
|
47
|
-
(_b = postData.params) === null || _b === void 0 ? void 0 : _b.forEach(function (param) {
|
|
48
|
-
push("encodedParams.set('".concat(param.name, "', '").concat(param.value, "');"));
|
|
49
|
-
});
|
|
50
|
-
reqOpts.body = 'encodedParams';
|
|
51
|
-
break;
|
|
52
|
-
case 'application/json':
|
|
53
|
-
if (postData.jsonObj) {
|
|
54
|
-
// Though `fetch` doesn't accept JSON objects in the `body` option we're going to
|
|
55
|
-
// stringify it when we add this into the snippet further down.
|
|
56
|
-
reqOpts.body = postData.jsonObj;
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case 'multipart/form-data':
|
|
60
|
-
if (!postData.params) {
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
// The `form-data` module automatically adds a `Content-Type` header for `multipart/form-data` content and if we add our own here data won't be correctly transmitted.
|
|
64
|
-
// eslint-disable-next-line no-case-declarations -- We're only using `contentTypeHeader` within this block.
|
|
65
|
-
var contentTypeHeader = (0, headers_1.getHeaderName)(headersObj, 'content-type');
|
|
66
|
-
if (contentTypeHeader) {
|
|
67
|
-
delete headersObj[contentTypeHeader];
|
|
68
|
-
}
|
|
69
|
-
unshift("const FormData = require('form-data');");
|
|
70
|
-
push('const formData = new FormData();');
|
|
71
|
-
blank();
|
|
72
|
-
postData.params.forEach(function (param) {
|
|
73
|
-
if (!param.fileName && !param.fileName && !param.contentType) {
|
|
74
|
-
push("formData.append('".concat(param.name, "', '").concat(param.value, "');"));
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (param.fileName) {
|
|
78
|
-
includeFS = true;
|
|
79
|
-
push("formData.append('".concat(param.name, "', fs.createReadStream('").concat(param.fileName, "'));"));
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
break;
|
|
83
|
-
default:
|
|
84
|
-
if (postData.text) {
|
|
85
|
-
reqOpts.body = postData.text;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// construct cookies argument
|
|
89
|
-
if (cookies.length) {
|
|
90
|
-
var cookiesString = cookies
|
|
91
|
-
.map(function (_a) {
|
|
92
|
-
var name = _a.name, value = _a.value;
|
|
93
|
-
return "".concat(encodeURIComponent(name), "=").concat(encodeURIComponent(value));
|
|
94
|
-
})
|
|
95
|
-
.join('; ');
|
|
96
|
-
if (reqOpts.headers) {
|
|
97
|
-
reqOpts.headers.cookie = cookiesString;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
reqOpts.headers = {};
|
|
101
|
-
reqOpts.headers.cookie = cookiesString;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
blank();
|
|
105
|
-
push("const url = '".concat(url, "';"));
|
|
106
|
-
// If we ultimately don't have any headers to send then we shouldn't add an empty object into the request options.
|
|
107
|
-
if (reqOpts.headers && !Object.keys(reqOpts.headers).length) {
|
|
108
|
-
delete reqOpts.headers;
|
|
109
|
-
}
|
|
110
|
-
var stringifiedOptions = (0, stringify_object_1.default)(reqOpts, {
|
|
111
|
-
indent: ' ',
|
|
112
|
-
inlineCharacterLimit: 80,
|
|
113
|
-
// The Fetch API body only accepts string parameters, but stringified JSON can be difficult to
|
|
114
|
-
// read, so we keep the object as a literal and use this transform function to wrap the literal
|
|
115
|
-
// in a `JSON.stringify` call.
|
|
116
|
-
transform: function (object, property, originalResult) {
|
|
117
|
-
if (property === 'body' && postData.mimeType === 'application/json') {
|
|
118
|
-
return "JSON.stringify(".concat(originalResult, ")");
|
|
119
|
-
}
|
|
120
|
-
return originalResult;
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
push("const options = ".concat(stringifiedOptions, ";"));
|
|
124
|
-
blank();
|
|
125
|
-
if (includeFS) {
|
|
126
|
-
unshift("const fs = require('fs');");
|
|
127
|
-
}
|
|
128
|
-
if (postData.params && postData.mimeType === 'multipart/form-data') {
|
|
129
|
-
push('options.body = formData;');
|
|
130
|
-
blank();
|
|
131
|
-
}
|
|
132
|
-
push('fetch(url, options)');
|
|
133
|
-
push('.then(res => res.json())', 1);
|
|
134
|
-
push('.then(json => console.log(json))', 1);
|
|
135
|
-
push(".catch(err => console.error('error:' + err));", 1);
|
|
136
|
-
return join()
|
|
137
|
-
.replace(/'encodedParams'/, 'encodedParams')
|
|
138
|
-
.replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/, 'fs.createReadStream("$1")');
|
|
139
|
-
},
|
|
140
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var URLSearchParams = require('url').URLSearchParams;
|
|
3
|
-
var fetch = require('node-fetch');
|
|
4
|
-
var encodedParams = new URLSearchParams();
|
|
5
|
-
encodedParams.set('foo', 'bar');
|
|
6
|
-
encodedParams.set('hello', 'world');
|
|
7
|
-
var url = 'https://httpbin.org/anything';
|
|
8
|
-
var options = {
|
|
9
|
-
method: 'POST',
|
|
10
|
-
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
11
|
-
body: encodedParams
|
|
12
|
-
};
|
|
13
|
-
fetch(url, options)
|
|
14
|
-
.then(function (res) { return res.json(); })
|
|
15
|
-
.then(function (json) { return console.log(json); })
|
|
16
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything';
|
|
4
|
-
var options = {
|
|
5
|
-
method: 'POST',
|
|
6
|
-
headers: { 'content-type': 'application/json' },
|
|
7
|
-
body: JSON.stringify({
|
|
8
|
-
number: 1,
|
|
9
|
-
string: 'f"oo',
|
|
10
|
-
arr: [1, 2, 3],
|
|
11
|
-
nested: { a: 'b' },
|
|
12
|
-
arr_mix: [1, 'a', { arr_mix_nested: [] }],
|
|
13
|
-
boolean: false
|
|
14
|
-
})
|
|
15
|
-
};
|
|
16
|
-
fetch(url, options)
|
|
17
|
-
.then(function (res) { return res.json(); })
|
|
18
|
-
.then(function (json) { return console.log(json); })
|
|
19
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/cookies';
|
|
4
|
-
var options = { method: 'GET', headers: { cookie: 'foo=bar; bar=baz' } };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything';
|
|
4
|
-
var options = { method: 'PROPFIND' };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var URLSearchParams = require('url').URLSearchParams;
|
|
3
|
-
var fetch = require('node-fetch');
|
|
4
|
-
var encodedParams = new URLSearchParams();
|
|
5
|
-
encodedParams.set('foo', 'bar');
|
|
6
|
-
var url = 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value';
|
|
7
|
-
var options = {
|
|
8
|
-
method: 'POST',
|
|
9
|
-
headers: {
|
|
10
|
-
accept: 'application/json',
|
|
11
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
12
|
-
cookie: 'foo=bar; bar=baz'
|
|
13
|
-
},
|
|
14
|
-
body: encodedParams
|
|
15
|
-
};
|
|
16
|
-
fetch(url, options)
|
|
17
|
-
.then(function (res) { return res.json(); })
|
|
18
|
-
.then(function (json) { return console.log(json); })
|
|
19
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/headers';
|
|
4
|
-
var options = {
|
|
5
|
-
method: 'GET',
|
|
6
|
-
headers: {
|
|
7
|
-
accept: 'application/json',
|
|
8
|
-
'x-foo': 'Bar',
|
|
9
|
-
'x-bar': 'Foo',
|
|
10
|
-
'quoted-value': '"quoted" \'string\''
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
fetch(url, options)
|
|
14
|
-
.then(function (res) { return res.json(); })
|
|
15
|
-
.then(function (json) { return console.log(json); })
|
|
16
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'http://httpbin.org/anything';
|
|
4
|
-
var options = { method: 'GET' };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything';
|
|
4
|
-
var options = {
|
|
5
|
-
method: 'POST',
|
|
6
|
-
headers: { 'content-type': 'application/json' },
|
|
7
|
-
body: JSON.stringify({ foo: 'bar' })
|
|
8
|
-
};
|
|
9
|
-
fetch(url, options)
|
|
10
|
-
.then(function (res) { return res.json(); })
|
|
11
|
-
.then(function (json) { return console.log(json); })
|
|
12
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything';
|
|
4
|
-
var options = {
|
|
5
|
-
method: 'POST',
|
|
6
|
-
headers: { 'content-type': 'application/json' },
|
|
7
|
-
body: JSON.stringify({ foo: null })
|
|
8
|
-
};
|
|
9
|
-
fetch(url, options)
|
|
10
|
-
.then(function (res) { return res.json(); })
|
|
11
|
-
.then(function (json) { return console.log(json); })
|
|
12
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fs = require('fs');
|
|
3
|
-
var FormData = require('form-data');
|
|
4
|
-
var fetch = require('node-fetch');
|
|
5
|
-
var formData = new FormData();
|
|
6
|
-
formData.append('foo', fs.createReadStream('src/fixtures/files/hello.txt'));
|
|
7
|
-
formData.append('bar', 'Bonjour le monde');
|
|
8
|
-
var url = 'https://httpbin.org/anything';
|
|
9
|
-
var options = { method: 'POST' };
|
|
10
|
-
options.body = formData;
|
|
11
|
-
fetch(url, options)
|
|
12
|
-
.then(function (res) { return res.json(); })
|
|
13
|
-
.then(function (json) { return console.log(json); })
|
|
14
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fs = require('fs');
|
|
3
|
-
var FormData = require('form-data');
|
|
4
|
-
var fetch = require('node-fetch');
|
|
5
|
-
var formData = new FormData();
|
|
6
|
-
formData.append('foo', fs.createReadStream('src/fixtures/files/hello.txt'));
|
|
7
|
-
var url = 'https://httpbin.org/anything';
|
|
8
|
-
var options = { method: 'POST' };
|
|
9
|
-
options.body = formData;
|
|
10
|
-
fetch(url, options)
|
|
11
|
-
.then(function (res) { return res.json(); })
|
|
12
|
-
.then(function (json) { return console.log(json); })
|
|
13
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything';
|
|
4
|
-
var options = { method: 'POST', headers: { 'Content-Type': 'multipart/form-data' } };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var FormData = require('form-data');
|
|
3
|
-
var fetch = require('node-fetch');
|
|
4
|
-
var formData = new FormData();
|
|
5
|
-
formData.append('foo', 'bar');
|
|
6
|
-
var url = 'https://httpbin.org/anything';
|
|
7
|
-
var options = { method: 'POST' };
|
|
8
|
-
options.body = formData;
|
|
9
|
-
fetch(url, options)
|
|
10
|
-
.then(function (res) { return res.json(); })
|
|
11
|
-
.then(function (json) { return console.log(json); })
|
|
12
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value';
|
|
4
|
-
var options = { method: 'GET' };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything';
|
|
4
|
-
var options = { method: 'POST', headers: { 'content-type': 'application/json' } };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything?startTime=2019-06-13T19%3A08%3A25.455Z&endTime=2015-09-15T14%3A00%3A12-04%3A00';
|
|
4
|
-
var options = { method: 'GET' };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value';
|
|
4
|
-
var options = { method: 'GET' };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything';
|
|
4
|
-
var options = { method: 'GET' };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fetch = require('node-fetch');
|
|
3
|
-
var url = 'https://httpbin.org/anything';
|
|
4
|
-
var options = { method: 'POST', headers: { 'content-type': 'text/plain' }, body: 'Hello World' };
|
|
5
|
-
fetch(url, options)
|
|
6
|
-
.then(function (res) { return res.json(); })
|
|
7
|
-
.then(function (json) { return console.log(json); })
|
|
8
|
-
.catch(function (err) { return console.error('error:' + err); });
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description
|
|
3
|
-
* HTTP code snippet generator for native Node.js.
|
|
4
|
-
*
|
|
5
|
-
* @author
|
|
6
|
-
* @AhmadNassri
|
|
7
|
-
*
|
|
8
|
-
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
9
|
-
*/
|
|
10
|
-
import type { Client } from '../../targets';
|
|
11
|
-
export declare const native: Client;
|