From c7cf84d1464bd98d7b7ba4a6ca3b2ce3b3fab761 Mon Sep 17 00:00:00 2001 From: raj356 Date: Sat, 20 Jul 2024 23:21:30 +0530 Subject: [PATCH] added doc for removeDefaultHeaders (#52) --- docs/.vitepress/config.ts | 1 + docs/api/settings/removeDefaultHeaders.md | 46 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 docs/api/settings/removeDefaultHeaders.md diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index adc82aae..7c128d83 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -180,6 +180,7 @@ const api_sidebar = [ { text: 'setRequestDefaultRetryCount', link: '/api/settings/setRequestDefaultRetryCount', }, { text: 'setRequestDefaultRetryDelay', link: '/api/settings/setRequestDefaultRetryDelay', }, { text: 'setDataDirectory', link: '/api/settings/setDataDirectory', }, + { text: 'removeDefaultHeaders', link: '/api/settings/removeDefaultHeaders', }, ] }, { diff --git a/docs/api/settings/removeDefaultHeaders.md b/docs/api/settings/removeDefaultHeaders.md new file mode 100644 index 00000000..854a25a3 --- /dev/null +++ b/docs/api/settings/removeDefaultHeaders.md @@ -0,0 +1,46 @@ +# removeDefaultHeaders + +use to remove default headers for all the requests. + +## Syntax + +```js +removeDefaultHeaders() +removeDefaultHeaders(key) +``` + +## Usage + +### ✅ Correct Usage + +```js +// without specifying any 'key' will remove all the default headers +request.removeDefaultHeaders() +``` + +```js +// by specifying 'key' will remove only the specific default header +request.removeDefaultHeaders('Authorization') +``` + +## Arguments + +#### > key (string) + +header key + + +## Examples + +### Normal + +```js +const { spec, request } = require('pactum'); + +request.setDefaultHeaders({ 'key': 'value', 'key1': 'value1' }); +request.removeDefaultHeaders('key'); + +await spec() + .get('https://randomuser.me/api') + .expectStatus(200); +``` \ No newline at end of file