Skip to content

Commit ee34cef

Browse files
authored
Update README.md
1 parent 930657c commit ee34cef

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,18 @@ fetch('/users', {
192192
status, define a custom response handler:
193193

194194
```javascript
195-
const checkStatus = response => {
196-
if (response.ok) {
197-
return response;
198-
} else {
195+
fetch('/users')
196+
.then(response => {
197+
if (response.ok) {
198+
return response;
199+
}
200+
// convert non-2xx HTTP responses into errors:
199201
const error = new Error(response.statusText);
200202
error.response = response;
201203
return Promise.reject(error);
202-
}
203-
}
204-
205-
fetch('/users')
206-
.then( checkStatus )
207-
.then( r => r.json() )
208-
.then( data => {
204+
})
205+
.then(response => response.json())
206+
.then(data => {
209207
console.log(data);
210208
});
211209
```

0 commit comments

Comments
 (0)