You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library is typed for convenient access to the documented API. If you need to access undocumented
207
+
endpoints, params, or response properties, the library can still be used.
208
+
209
+
#### Undocumented endpoints
210
+
211
+
To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.
212
+
Options on the client, such as retries, will be respected when making these requests.
213
+
214
+
```ts
215
+
awaitclient.post('/some/path', {
216
+
body: { some_prop: 'foo' },
217
+
query: { some_query_arg: 'bar' },
218
+
});
219
+
```
220
+
221
+
#### Undocumented params
222
+
223
+
To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
224
+
parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
225
+
send will be sent as-is.
226
+
227
+
```ts
228
+
client.foo.create({
229
+
foo: 'my_param',
230
+
bar: 12,
231
+
// @ts-expect-error baz is not yet public
232
+
baz: 'undocumented option',
233
+
});
234
+
```
235
+
236
+
For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
237
+
extra param in the body.
238
+
239
+
If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
240
+
options.
241
+
242
+
#### Undocumented properties
243
+
244
+
To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
245
+
the response object, or cast the response object to the requisite type. Like the request params, we do not
246
+
validate or strip extra properties from the response from the API.
247
+
248
+
### Customizing the fetch client
205
249
206
250
By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.
207
251
@@ -219,6 +263,8 @@ import Cloudflare from 'cloudflare';
219
263
To do the inverse, add `import "cloudflare/shims/node"` (which does import polyfills).
220
264
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/cloudflare/cloudflare-typescript/tree/main/src/_shims#readme)).
221
265
266
+
### Logging and middleware
267
+
222
268
You may also provide a custom `fetch` function when instantiating the client,
223
269
which can be used to inspect or alter the `Request` or `Response` before/after each request:
224
270
@@ -239,7 +285,7 @@ const client = new Cloudflare({
239
285
Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.
240
286
This is intended for debugging purposes only and may change in the future without notice.
241
287
242
-
## Configuring an HTTP(S) Agent (e.g., for proxies)
288
+
###Configuring an HTTP(S) Agent (e.g., for proxies)
243
289
244
290
By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests.
0 commit comments