diff --git a/CHANGELOG.md b/CHANGELOG.md index 229cff746..ccbee1d14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ [#1442](https://github.com/nextcloud/cookbook/pull/1442) @christianlupus - Reorder arrows are no longer hidden [#1446](https://github.com/nextcloud/cookbook/pull/1446) @christianlupus +- Add network logging for responses, not only requests + [1405](https://github.com/nextcloud/cookbook/pull/1405) @MarcelRobitaille ### Maintenance - Update dependency for GitHub pages builder diff --git a/src/js/api-interface.js b/src/js/api-interface.js index faffa46b3..ae92f1b62 100644 --- a/src/js/api-interface.js +++ b/src/js/api-interface.js @@ -10,18 +10,29 @@ const baseUrl = `${generateUrl("apps/cookbook")}/webapp` // Add a debug log for every request instance.interceptors.request.use((config) => { Vue.$log.debug( - `Making "${config.method}" request to "${config.url}"`, + `[axios] Making "${config.method}" request to "${config.url}"`, config ) const contentType = config.headers[config.method]["Content-Type"] if (!["application/json", "text/json"].includes(contentType)) { Vue.$log.warn( - `Request to "${config.url}" is using Content-Type "${contentType}", not JSON` + `[axios] Request to "${config.url}" is using Content-Type "${contentType}", not JSON` ) } return config }) +instance.interceptors.response.use( + (response) => { + Vue.$log.debug("[axios] Received response", response) + return response + }, + (error) => { + Vue.$log.warn("[axios] Received error", error) + return Promise.reject(error) + } +) + axios.defaults.headers.common.Accept = "application/json" function createNewRecipe(recipe) {