mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-18 11:58:24 +01:00
fix undefined response error caused by empty response body
This commit is contained in:
parent
8150bc946b
commit
5f6ab54c83
@ -236,8 +236,10 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
{
|
{
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const signal = controller.signal;
|
const signal = controller.signal;
|
||||||
|
let response_ok = false;
|
||||||
promise = (this.egw.window?this.egw.window:window).fetch(url, {...init, ...signal})
|
promise = (this.egw.window?this.egw.window:window).fetch(url, {...init, ...signal})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
response_ok = response.ok;
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw response;
|
throw response;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,11 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
})
|
})
|
||||||
.then((data) => this.handleResponse(data) || data)
|
.then((data) => this.handleResponse(data) || data)
|
||||||
.catch((_err) => {
|
.catch((_err) => {
|
||||||
(error || this.handleError).call(this, _err)
|
// no response / empty body causing response.json() to throw (a different error per browser!)
|
||||||
|
if (response_ok && !_err.message.match(/Unexpected end of/i))
|
||||||
|
{
|
||||||
|
(error || this.handleError).call(this, _err)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// offering a simple abort mechanism and compatibility with jQuery.ajax
|
// offering a simple abort mechanism and compatibility with jQuery.ajax
|
||||||
|
Loading…
Reference in New Issue
Block a user