response.okĬonvenience property representing if the request ended normally. The constructor is identical to that in the browser.īecause Node.js does not implement service workers (for which this class was designed), one rarely has to construct a Response directly. options A ResponseInit options dictionaryĬonstructs a new Response object.The following properties are not implemented in node-fetch at this moment: This class implements the Body interface. In most cases, directly fetch(url, options) is simpler than creating a Request object.Īn HTTP(S) response. The constructor is identical to that in the browser. options Options for the HTTP(S) requestĬonstructs a new Request object.input A string representing a URL, or another Request (which will be cloned).See options for exact meaning of these extensions. The following node-fetch extension properties are provided: This class implements the Body interface.ĭue to the nature of Node.js, the following properties are not implemented at this moment: Import fetch from 'node-fetch' class HTTPResponseError extends Error Īn HTTP(S) request containing information about URL, method, headers, and the body. If you happen to use a missing feature that window.fetch offers, feel free to open an issue.Ĭurrent stable release ( 3.x) requires at least Node.js 12.20.0.Useful extensions such as redirect limit, response size limit, explicit errors for troubleshooting.Decode content encoding (gzip/deflate/brotli) properly, and convert string output (such as res.text() and res.json()) to UTF-8 automatically. ![]()
0 Comments
Leave a Reply. |