We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 930657c commit ee34cefCopy full SHA for ee34cef
README.md
@@ -192,20 +192,18 @@ fetch('/users', {
192
status, define a custom response handler:
193
194
```javascript
195
-const checkStatus = response => {
196
- if (response.ok) {
197
- return response;
198
- } else {
+fetch('/users')
+ .then(response => {
+ if (response.ok) {
+ return response;
199
+ }
200
+ // convert non-2xx HTTP responses into errors:
201
const error = new Error(response.statusText);
202
error.response = response;
203
return Promise.reject(error);
- }
-}
204
-
205
-fetch('/users')
206
- .then( checkStatus )
207
- .then( r => r.json() )
208
- .then( data => {
+ })
+ .then(response => response.json())
+ .then(data => {
209
console.log(data);
210
});
211
```
0 commit comments