debug()
Function Signature
debug: () => R
Output Format
`[${config.options.method}] ${config.label ? config.label : ''} Current Config:`, config
Description
debug() prints the current request builder configuration to the console. Use it to inspect the config state in the middle of a chain without adding a separate console.log().
debug() does not execute the request, and it returns the same builder type so the chain can continue.
Example
import { dench } from 'dench-fetch';
const result = await dench('https://api.example.com', 'Users')
.get('/users')
.auth('access-token')
.debug()
.toJson();
The console output uses this shape.
[GET] Users Current Config: {
label: 'Users',
baseURL: 'https://api.example.com',
api: '/users',
URLNormalize: DenchURLNormalizeMode.BOUNDARY,
options: {
method: 'GET',
headers: {
Authorization: 'Bearer access-token',
},
},
}
Notes
debug()prints the configuration at the point where it is called.- Settings added later in the chain are not included in an earlier
debug()output. - To inspect the final request configuration, call it immediately before a runner method such as
toJson(),toResponse(), ortoFormData().
const result = await dench('https://api.example.com')
.get('/users')
.debug()
.auth('access-token')
.toJson();
The output from the example above does not include the later auth() setting.