Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
Tied up response handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Jul 10, 2020
1 parent 009644e commit 3af7158
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions resources/js/larapass.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class Larapass
* Throws the entire response if is not OK (HTTP 2XX).
*
* @param response {Response}
* @returns Promise<JSON|ArrayBuffer|ArrayBufferView|Blob|FormData|string|URLSearchParams>
* @returns Promise<JSON|ReadableStream>
* @throws Response
*/
static #handleResponse(response)
Expand All @@ -245,11 +245,9 @@ class Larapass
// are JSON, we will automatically parse the JSON body from the response. If
// it's not JSON, we will push the body verbatim and let the dev handle it.
return new Promise(resolve => {
if (response) {
response.json().then(json => resolve(json)).catch(() => resolve(response.body))
} else {
resolve(response.body)
}
response.json()
.then(json => resolve(json))
.catch(() => resolve(response.body))
})
}

Expand Down

0 comments on commit 3af7158

Please sign in to comment.