diff --git a/addons/web/static/src/core/network/http_service.js b/addons/web/static/src/core/network/http_service.js index 8c5e50789a1..13f25142ebe 100644 --- a/addons/web/static/src/core/network/http_service.js +++ b/addons/web/static/src/core/network/http_service.js @@ -2,11 +2,18 @@ import { registry } from "../registry"; +function checkResponseStatus(response) { + if (response.status === 502) { + throw new Error("Failed to fetch"); + } +} + export const httpService = { start() { return { async get(route, readMethod = "json") { const response = await fetch(route, { method: "GET" }); + checkResponseStatus(response); return response[readMethod](); }, async post(route, params = {}, readMethod = "json") { @@ -26,6 +33,7 @@ export const httpService = { method: "POST", }; const response = await fetch(route, info); + checkResponseStatus(response); return response[readMethod](); }, };