fetch-with-json
Advanced tools
+3
-2
| { | ||
| "name": "fetch-with-json", | ||
| "description": "Some tweaks to the Fetch API to make it easier to communicate with the server using JSON.", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "main": "lib/index.js", | ||
@@ -16,4 +16,5 @@ "types": "es/index.d.ts", | ||
| "build:lib": "tsc --outDir lib", | ||
| "dev": "tsc --outDir es --module esnext --watch --pretty false --preserveWatchOutput true", | ||
| "format": "prettier --write .", | ||
| "dev": "tsc --outDir es --module esnext --watch --pretty false --preserveWatchOutput true" | ||
| "release": "npm run build && npm publish --registry=https://registry.npmjs.org/" | ||
| }, | ||
@@ -20,0 +21,0 @@ "keywords": [ |
+5
-1
@@ -13,3 +13,3 @@ # Fetch with JSON | ||
| - Stringify the request data (the `json` field in the options) with `JSON.stringify` before sending it to the server as request body. [See the example here](#1-post-json-to-the-server). | ||
| - Stringify the request data (the `json` field in the options) with `JSON.stringify` before sending it to the server as request body. [See the example here](#1-posting-json-data). | ||
| - Set the request header `Content-Type` to `application/json` and `Accept` to `application/json, */*` if they are not set. | ||
@@ -134,2 +134,6 @@ - Always try to parse response body as JSON no matter what the response header `Content-Type` is and assign the parsed result to `response.json`. If error has be thrown during parsing, `response.json` will be set to the text of the original response body, and the error will be assigned to `response.error`. | ||
| Please note that we are using the `body` field to upload the [FormData][form_data] instead of using the `json` field. The `body` field is declared in [the parameters of the Fetch API][fetch_params]. When `body` is set (not `null` or `undefined`), the `json` field will be ignored. | ||
| [form_data]: https://developer.mozilla.org/en-US/docs/Web/API/FormData | ||
| ### 5. Getting the original Response | ||
@@ -136,0 +140,0 @@ |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
23072
1.92%308
1.32%1
Infinity%