We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 58ce038 commit 0c966e6Copy full SHA for 0c966e6
lib/api.ts
@@ -40,14 +40,28 @@ export const api = async (
40
logger.log('HTTP Response:', res);
41
}
42
43
- return await res.json();
+ try {
44
+ const responseData = await res.json();
45
+
46
+ if (logger) {
47
+ logger.log('Response Data:', responseData);
48
+ }
49
50
+ return responseData;
51
+ } catch (e) {
52
53
+ logger.warn('Failed to parse response as JSON:', e);
54
55
+ return undefined;
56
57
} catch (error) {
58
const duration = Date.now() - startTime;
59
60
if (logger) {
61
logger.error('HTTP Request Failed:', {
62
error,
- duration: `${duration}ms`
63
+ duration: `${duration}ms`,
64
+ url
65
});
66
67
0 commit comments