# HG changeset patch # User Yaroslav Zhuravlev # Date 1675346763 0 # Node ID 386ba17fac2398fea1375d508e99766b5f873a00 # Parent 16613b91c58419f6e454446066de6862d1abea68 Documented Request, Response, Headers in Fetch API. diff -r 16613b91c584 -r 386ba17fac23 xml/en/docs/njs/reference.xml --- a/xml/en/docs/njs/reference.xml Thu Feb 02 13:45:06 2023 +0000 +++ b/xml/en/docs/njs/reference.xml Thu Feb 02 14:06:03 2023 +0000 @@ -9,7 +9,7 @@
+ rev="97">
@@ -911,11 +911,164 @@
+
+ + +The Headers interface of the +Fetch API +is available since 0.5.1. + + + +A new Headers object can be created using +the Headers() constructor +(since 0.7.10) +with the following properties and methods: + + + +append() + +Appends a new value into an existing header in the +Headers object, +or adds the header if it does not already exist +(since 0.7.10). + + +delete() + +Deletes a header from the Headers object +(since 0.7.10). + + +get() + +Returns a string containing the values of all headers with the specified name +separated by a comma and a space. + + +getAll(name) + +Returns an array containing the values of all headers with the specified name. + + +forEach() + +Executes a provided function once for each key/value pair +in the Headers object +(since 0.7.10). + + +has() + +Returns a boolean value +indicating whether a header with the specified name exists. + + +set() + +Sets a new value for an existing header inside +the Headers object, +or adds the header if it does not already exist +(since 0.7.10). + + + + + +
+ + +
+ + +The Request interface of the +Fetch API +is available since 0.7.10. + + + +A new Request object can be created using +the Request() constructor +with the following properties and methods: + + + +arrayBuffer() + +Returns a Promise that resolves with +an ArrayBuffer. + + +bodyUsed + +A boolean value, true +if the body was used in the request. + + +cache + +Contains the cache mode of the request. + + +credentials + +Contains the credentials of the request, +by default is same-origin. + + +headers + +The Headers read-only object +associated with the +Request. + + +json() + +Returns a Promise that resolves with +the result of parsing the request body as JSON. + + +method + +Contains the request method. + + +mode + +Contains the mode of the request. + + +text() + +Returns a Promise that resolves with a +string representation of the request body. + + +url + +Contains the URL of the request. + + + + + +
+ +
The Response interface is available since 0.5.1. + + + +A new Response object can be created using +the Response() constructor +(since 0.7.10) +with the following properties and methods: @@ -934,29 +1087,9 @@ headers -The Headers read-only object associated with the -Response: - - - -get(name) - -returns a string containing the values of all headers with the specified name -separated by a comma and a space - - -getAll(name) - -returns an array containing the values of all headers with the specified name - - -has(name) - -returns a boolean value -indicating whether a header with the specified name exists - - - +The Headers read-only object +associated with the +Response. json() @@ -1025,12 +1158,14 @@ (0.7.8) -ngx.fetch(url, +ngx.fetch(resource, [options]) -Makes a request to fetch an URL -(0.5.1), -returns a Promise that resolves with +Makes a request to fetch a resource +(0.5.1), which can be an +URL or the Request object +(0.7.10). +Returns a Promise that resolves with the Response object. Since 0.7.0, the https:// scheme is supported, @@ -1054,7 +1189,7 @@ headers -request headers object +request headers object max_response_body_size