Search.../

statusText

The response status message.

Type:

stringRead Only

Was this helpful?

Get the response's status message.

Copy Code
1let statusText = httpResponse.statusText; // "OK"
Get a resource and the response information

Copy Code
1import {fetch} from 'wix-fetch';
2
3// ...
4
5fetch("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 } );