mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +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 signal = controller.signal;
|
||||
let response_ok = false;
|
||||
promise = (this.egw.window?this.egw.window:window).fetch(url, {...init, ...signal})
|
||||
.then((response) => {
|
||||
response_ok = response.ok;
|
||||
if (!response.ok) {
|
||||
throw response;
|
||||
}
|
||||
@ -245,7 +247,11 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
||||
})
|
||||
.then((data) => this.handleResponse(data) || data)
|
||||
.catch((_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
|
||||
|
Loading…
Reference in New Issue
Block a user