Fix custom API response parsing not working
This commit is contained in:
parent
a8f9138001
commit
25df85b91f
|
@ -83,6 +83,7 @@ export const createAPIClient = config => {
|
||||||
body,
|
body,
|
||||||
json = true,
|
json = true,
|
||||||
external = false,
|
external = false,
|
||||||
|
parseResponse,
|
||||||
}) => {
|
}) => {
|
||||||
// Ensure we don't do JSON processing if sending a GET request
|
// Ensure we don't do JSON processing if sending a GET request
|
||||||
json = json && method !== "GET"
|
json = json && method !== "GET"
|
||||||
|
@ -125,8 +126,8 @@ export const createAPIClient = config => {
|
||||||
// Handle response
|
// Handle response
|
||||||
if (response.status >= 200 && response.status < 400) {
|
if (response.status >= 200 && response.status < 400) {
|
||||||
try {
|
try {
|
||||||
if (config?.parseResponse) {
|
if (parseResponse) {
|
||||||
return await config.parseResponse(response)
|
return await parseResponse(response)
|
||||||
} else {
|
} else {
|
||||||
return await response.json()
|
return await response.json()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue