@tatil/server-api 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tatil/server-api",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Tatilsepeti Server Api for Next.js server-side operations",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -12,10 +12,34 @@ class TatilsepetiApi {
12
12
  this.instance = axios.create({
13
13
  baseURL: API_URL,
14
14
  });
15
+
15
16
  this.logger = RequestLogger();
16
17
  this.defaultHeaders = {
17
18
  'Content-Type': 'application/json',
18
19
  };
20
+
21
+ this.attachInterceptors();
22
+ }
23
+
24
+ attachInterceptors() {
25
+ this.instance.interceptors.response.use(
26
+ (response) => {
27
+ console.log('[API RESPONSE]', {
28
+ url: response.config.url,
29
+ status: response.status,
30
+ data: response.data,
31
+ });
32
+ return response;
33
+ },
34
+ (error) => {
35
+ console.error('[API RESPONSE ERROR]', {
36
+ url: error.config?.url,
37
+ status: error.response?.status,
38
+ data: error.response?.data,
39
+ });
40
+ return Promise.reject(error);
41
+ }
42
+ );
19
43
  }
20
44
 
21
45
  joinEndpoint(endpoint) {