Search...
bodyUsed
Indicates whether the body of the response has been used yet.
Description
The response's body is considered used once it has been read. For example,
after calling the response's json()
function, the value of
bodyUsed
will be true
.
Type:
booleanRead Only
Was this helpful?
Get whether the response's body has been used.
Copy Code
1let wasBodyUsed = httpResponse.bodyUsed; // false
Get a resource and the response information
Copy Code
1import {fetch} from 'wix-fetch';23// ...45fetch("https://someapi.com/api/someendpoint", {"method": "get"})6 .then( (httpResponse) => {7 let url = httpResponse.url;8 let statusCode = httpResponse.status;9 let statusText = httpResponse.statusText;10 let headers = httpResponse.headers;11 let bodyUsed = httpResponse.bodyUsed;12 if (httpResponse.ok) {13 return httpResponse.json();14 }15 else {16 return Promise.reject("Fetch did not succeed");17 }18 } )19 .then( (json) => {20 console.log(json.someKey);21 } )22 .catch( (err) => {23 console.log(err);24 } );