-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation update for follow redirects (#55)
- Loading branch information
1 parent
936344b
commit 5e17ff5
Showing
4 changed files
with
170 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
tags: | ||
- redirects | ||
- follow redirects | ||
--- | ||
|
||
# setDefaultFollowRedirects | ||
|
||
set default Follow Redirects for all the requests. | ||
|
||
::: tip Tip | ||
Default value for follow redirects is false / disabled | ||
::: | ||
|
||
## Syntax | ||
|
||
```js | ||
setDefaultFollowRedirects(follow) | ||
``` | ||
|
||
## Usage | ||
|
||
### ✅ Correct Usage | ||
|
||
```js | ||
// Boolean parameter - defaults to count 20 | ||
request.setDefaultFollowRedirects(true) | ||
``` | ||
|
||
```js | ||
// Absolute follow redirect count | ||
request.setDefaultFollowRedirects(5) | ||
``` | ||
|
||
## Arguments | ||
|
||
#### > follow (boolean) | ||
|
||
Toggle follow redirects | ||
|
||
#### > follow (number) | ||
|
||
Toggle follow redirects and set the absolute redirect count. | ||
|
||
|
||
|
||
## Examples | ||
|
||
### Normal | ||
|
||
```js | ||
const { spec, request } = require('pactum'); | ||
|
||
request.setDefaultFollowRedirects(true); | ||
|
||
await spec() | ||
.get('https://httpbin.org/redirect-to') | ||
.withQueryParams('url', 'https://httpbin.org/status/200') | ||
.expectStatus(200); | ||
``` | ||
|
||
```js | ||
const { spec, request } = require('pactum'); | ||
|
||
request.setDefaultFollowRedirects(5); | ||
|
||
await spec() | ||
.get('https://httpbin.org/redirect-to') | ||
.withQueryParams('url', 'https://httpbin.org/status/200') | ||
.expectStatus(200); | ||
``` | ||
|
||
::: tip Tip | ||
Follow redirects count should be greater than or equal to number of redirects on the server side for the request. | ||
::: | ||
|
||
|
||
## See Also | ||
|
||
- [withFollowRedirects](/api/requests/withFollowRedirects) |