Skip to content

Commit

Permalink
Network error handling fixes.
Browse files Browse the repository at this point in the history
Fixes #38.
  • Loading branch information
jaydenseric committed Nov 9, 2017
1 parent 70cfa4f commit edfa6ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# apollo-upload-client change log

## Next

* Corrected network error handling, fixing
[#38](https://github.com/jaydenseric/apollo-upload-client/issues/38).

## 6.0.0-beta.2

* Match the `apollo-link-http` API and support setting `credentials` and
Expand Down
17 changes: 6 additions & 11 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,15 @@ export const createUploadLink = (
}

linkFetch(uri, fetchOptions)
.then(response =>
response.json().then(result => {
if (!response.ok)
throw new Error(
`Error ${response.status}: ${response.statusText}.`
)

return result
})
)
.then(response => {
if (!response.ok)
throw new Error(`${response.status} (${response.statusText})`)
return response.json()
})
.then(result => {
observer.next(result)
observer.complete()
})
.catch(observer.error)
.catch(error => observer.error(error))
})
)

0 comments on commit edfa6ca

Please sign in to comment.