Skip to content

Commit bee1a04

Browse files
Add network logging for responses, not only requests
Signed-off-by: Marcel Robitaille <[email protected]> Signed-off-by: Christian Wolf <[email protected]>
1 parent ed9ddde commit bee1a04

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
[#1442](https://github.com/nextcloud/cookbook/pull/1442) @christianlupus
88
- Reorder arrows are no longer hidden
99
[#1446](https://github.com/nextcloud/cookbook/pull/1446) @christianlupus
10+
- Add network logging for responses, not only requests
11+
[1405](https://github.com/nextcloud/cookbook/pull/1405) @MarcelRobitaille
1012

1113
### Maintenance
1214
- Update dependency for GitHub pages builder

src/js/api-interface.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,29 @@ const baseUrl = `${generateUrl("apps/cookbook")}/webapp`
1010
// Add a debug log for every request
1111
instance.interceptors.request.use((config) => {
1212
Vue.$log.debug(
13-
`Making "${config.method}" request to "${config.url}"`,
13+
`[axios] Making "${config.method}" request to "${config.url}"`,
1414
config
1515
)
1616
const contentType = config.headers[config.method]["Content-Type"]
1717
if (!["application/json", "text/json"].includes(contentType)) {
1818
Vue.$log.warn(
19-
`Request to "${config.url}" is using Content-Type "${contentType}", not JSON`
19+
`[axios] Request to "${config.url}" is using Content-Type "${contentType}", not JSON`
2020
)
2121
}
2222
return config
2323
})
2424

25+
instance.interceptors.response.use(
26+
(response) => {
27+
Vue.$log.debug("[axios] Received response", response)
28+
return response
29+
},
30+
(error) => {
31+
Vue.$log.warn("[axios] Received error", error)
32+
return Promise.reject(error)
33+
}
34+
)
35+
2536
axios.defaults.headers.common.Accept = "application/json"
2637

2738
function createNewRecipe(recipe) {

0 commit comments

Comments
 (0)