Search...
headers
The response headers.
Type:
ObjectRead Only
Was this helpful?
Get the response's headers.
Copy Code
1let headers = httpResponse.headers;
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 } );