2021-09-13 12:43:07 -07:00
|
|
|
# class: FetchRequest
|
2021-09-14 12:56:09 -07:00
|
|
|
* langs: js
|
2021-09-13 12:43:07 -07:00
|
|
|
|
|
|
|
This API is used for Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
|
|
|
|
environment or the service to your e2e test. When used on [Page] or a [BrowserContext], this API will automatically use
|
|
|
|
the cookies from the corresponding [BrowserContext]. This means that if you log in using this API, your e2e test
|
|
|
|
will be logged in and vice versa.
|
|
|
|
|
2021-09-15 14:02:55 -07:00
|
|
|
## async method: FetchRequest.dispose
|
|
|
|
|
|
|
|
All responses received through [`method: FetchRequest.fetch`], [`method: FetchRequest.get`], [`method: FetchRequest.post`]
|
|
|
|
and other methods are stored in the memory, so that you can later call [`method: FetchResponse.body`]. This method
|
|
|
|
discards all stored responses, and makes [`method: FetchResponse.body`] throw "Response disposed" error.
|
|
|
|
|
2021-09-13 12:43:07 -07:00
|
|
|
## async method: FetchRequest.fetch
|
|
|
|
- returns: <[FetchResponse]>
|
|
|
|
|
|
|
|
Sends HTTP(S) fetch and returns its response. The method will populate fetch cookies from the context and update
|
|
|
|
context cookies from the response. The method will automatically follow redirects.
|
|
|
|
|
|
|
|
### param: FetchRequest.fetch.urlOrRequest
|
|
|
|
- `urlOrRequest` <[string]|[Request]>
|
|
|
|
|
|
|
|
Target URL or Request to get all fetch parameters from.
|
|
|
|
|
2021-09-13 14:29:44 -07:00
|
|
|
### option: FetchRequest.fetch.params
|
|
|
|
- `params` <[Object]<[string], [string]>>
|
|
|
|
|
|
|
|
Query parameters to be send with the URL.
|
|
|
|
|
2021-09-13 12:43:07 -07:00
|
|
|
### option: FetchRequest.fetch.method
|
|
|
|
- `method` <[string]>
|
|
|
|
|
|
|
|
If set changes the fetch method (e.g. PUT or POST). If not specified, GET method is used.
|
|
|
|
|
|
|
|
### option: FetchRequest.fetch.headers
|
|
|
|
- `headers` <[Object]<[string], [string]>>
|
|
|
|
|
|
|
|
Allows to set HTTP headers.
|
|
|
|
|
2021-10-01 12:11:33 -07:00
|
|
|
### option: FetchRequest.fetch.data = %%-fetch-option-data-%%
|
2021-09-13 12:43:07 -07:00
|
|
|
|
2021-10-01 12:11:33 -07:00
|
|
|
### option: FetchRequest.fetch.form = %%-fetch-option-form-%%
|
|
|
|
|
|
|
|
### option: FetchRequest.fetch.multipart = %%-fetch-option-multipart-%%
|
2021-09-13 12:43:07 -07:00
|
|
|
|
|
|
|
### option: FetchRequest.fetch.timeout
|
|
|
|
- `timeout` <[float]>
|
|
|
|
|
|
|
|
Request timeout in milliseconds.
|
|
|
|
|
2021-09-13 15:38:27 -07:00
|
|
|
### option: FetchRequest.fetch.failOnStatusCode
|
|
|
|
- `failOnStatusCode` <[boolean]>
|
|
|
|
|
|
|
|
Whether to throw on response codes other than 2xx and 3xx. By default response object is returned
|
|
|
|
for all status codes.
|
|
|
|
|
2021-09-28 15:33:36 -07:00
|
|
|
### option: FetchRequest.fetch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
|
|
|
|
2021-09-13 12:43:07 -07:00
|
|
|
## async method: FetchRequest.get
|
|
|
|
- returns: <[FetchResponse]>
|
|
|
|
|
|
|
|
Sends HTTP(S) GET request and returns its response. The method will populate fetch cookies from the context and update
|
|
|
|
context cookies from the response. The method will automatically follow redirects.
|
|
|
|
|
2021-10-05 16:36:15 -07:00
|
|
|
### param: FetchRequest.get.url
|
|
|
|
- `url` <[string]>
|
2021-09-13 12:43:07 -07:00
|
|
|
|
2021-10-05 16:36:15 -07:00
|
|
|
Target URL.
|
2021-09-13 12:43:07 -07:00
|
|
|
|
2021-09-13 14:29:44 -07:00
|
|
|
### option: FetchRequest.get.params
|
|
|
|
- `params` <[Object]<[string], [string]>>
|
|
|
|
|
|
|
|
Query parameters to be send with the URL.
|
|
|
|
|
2021-09-13 12:43:07 -07:00
|
|
|
### option: FetchRequest.get.headers
|
|
|
|
- `headers` <[Object]<[string], [string]>>
|
|
|
|
|
|
|
|
Allows to set HTTP headers.
|
|
|
|
|
|
|
|
### option: FetchRequest.get.timeout
|
|
|
|
- `timeout` <[float]>
|
|
|
|
|
|
|
|
Request timeout in milliseconds.
|
|
|
|
|
2021-09-13 15:38:27 -07:00
|
|
|
### option: FetchRequest.get.failOnStatusCode
|
|
|
|
- `failOnStatusCode` <[boolean]>
|
|
|
|
|
|
|
|
Whether to throw on response codes other than 2xx and 3xx. By default response object is returned
|
|
|
|
for all status codes.
|
|
|
|
|
2021-09-28 15:33:36 -07:00
|
|
|
### option: FetchRequest.get.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
|
|
|
|
2021-09-13 12:43:07 -07:00
|
|
|
## async method: FetchRequest.post
|
|
|
|
- returns: <[FetchResponse]>
|
|
|
|
|
|
|
|
Sends HTTP(S) fetch and returns its response. The method will populate fetch cookies from the context and update
|
|
|
|
context cookies from the response. The method will automatically follow redirects.
|
|
|
|
|
2021-10-05 16:36:15 -07:00
|
|
|
### param: FetchRequest.post.url
|
|
|
|
- `url` <[string]>
|
2021-09-13 12:43:07 -07:00
|
|
|
|
2021-10-05 16:36:15 -07:00
|
|
|
Target URL.
|
2021-09-13 12:43:07 -07:00
|
|
|
|
2021-09-13 14:29:44 -07:00
|
|
|
### option: FetchRequest.post.params
|
|
|
|
- `params` <[Object]<[string], [string]>>
|
|
|
|
|
|
|
|
Query parameters to be send with the URL.
|
|
|
|
|
2021-09-13 12:43:07 -07:00
|
|
|
### option: FetchRequest.post.headers
|
|
|
|
- `headers` <[Object]<[string], [string]>>
|
|
|
|
|
|
|
|
Allows to set HTTP headers.
|
|
|
|
|
2021-10-01 12:11:33 -07:00
|
|
|
### option: FetchRequest.post.data = %%-fetch-option-data-%%
|
|
|
|
|
|
|
|
### option: FetchRequest.post.form = %%-fetch-option-form-%%
|
2021-09-13 12:43:07 -07:00
|
|
|
|
2021-10-01 12:11:33 -07:00
|
|
|
### option: FetchRequest.post.multipart = %%-fetch-option-multipart-%%
|
2021-09-13 12:43:07 -07:00
|
|
|
|
|
|
|
### option: FetchRequest.post.timeout
|
|
|
|
- `timeout` <[float]>
|
|
|
|
|
|
|
|
Request timeout in milliseconds.
|
2021-09-13 15:38:27 -07:00
|
|
|
|
|
|
|
### option: FetchRequest.post.failOnStatusCode
|
|
|
|
- `failOnStatusCode` <[boolean]>
|
|
|
|
|
|
|
|
Whether to throw on response codes other than 2xx and 3xx. By default response object is returned
|
|
|
|
for all status codes.
|
2021-09-28 15:33:36 -07:00
|
|
|
|
|
|
|
### option: FetchRequest.post.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
2021-09-30 14:14:29 -07:00
|
|
|
|
|
|
|
## async method: FetchRequest.storageState
|
|
|
|
- returns: <[Object]>
|
|
|
|
- `cookies` <[Array]<[Object]>>
|
|
|
|
- `name` <[string]>
|
|
|
|
- `value` <[string]>
|
|
|
|
- `domain` <[string]>
|
|
|
|
- `path` <[string]>
|
|
|
|
- `expires` <[float]> Unix time in seconds.
|
|
|
|
- `httpOnly` <[boolean]>
|
|
|
|
- `secure` <[boolean]>
|
|
|
|
- `sameSite` <[SameSiteAttribute]<"Strict"|"Lax"|"None">>
|
|
|
|
- `origins` <[Array]<[Object]>>
|
|
|
|
- `origin` <[string]>
|
|
|
|
- `localStorage` <[Array]<[Object]>>
|
|
|
|
- `name` <[string]>
|
|
|
|
- `value` <[string]>
|
|
|
|
|
|
|
|
Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to the constructor.
|
|
|
|
|
|
|
|
### option: FetchRequest.storageState.path = %%-storagestate-option-path-%%
|