@ethersphere/bee-js 6.0.0-pre.2 → 6.0.0-pre.3

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.
@@ -53,6 +53,9 @@ class BeeDebug {
53
53
  if (options?.headers) {
54
54
  requestOptions.headers = options.headers;
55
55
  }
56
+ if (options?.onRequest) {
57
+ requestOptions.onRequest = options.onRequest;
58
+ }
56
59
  this.requestOptions = requestOptions;
57
60
  }
58
61
  async getNodeAddresses(options) {
package/dist/cjs/bee.js CHANGED
@@ -80,6 +80,9 @@ class Bee {
80
80
  if (options?.headers) {
81
81
  requestOptions.headers = options.headers;
82
82
  }
83
+ if (options?.onRequest) {
84
+ requestOptions.onRequest = options.onRequest;
85
+ }
83
86
  this.requestOptions = requestOptions;
84
87
  }
85
88
  /**
@@ -9,7 +9,6 @@ const cafe_utility_1 = require("cafe-utility");
9
9
  exports.DEFAULT_HTTP_CONFIG = {
10
10
  headers: {
11
11
  accept: 'application/json, text/plain, */*',
12
- 'user-agent': `bee-js`,
13
12
  },
14
13
  };
15
14
  /**
@@ -20,6 +19,7 @@ exports.DEFAULT_HTTP_CONFIG = {
20
19
  async function http(options, config) {
21
20
  try {
22
21
  const requestConfig = cafe_utility_1.Objects.deepMerge3(exports.DEFAULT_HTTP_CONFIG, config, options);
22
+ maybeRunOnRequestHook(options, requestConfig);
23
23
  const response = await (0, axios_1.default)(requestConfig);
24
24
  return response;
25
25
  }
@@ -28,3 +28,13 @@ async function http(options, config) {
28
28
  }
29
29
  }
30
30
  exports.http = http;
31
+ function maybeRunOnRequestHook(options, requestConfig) {
32
+ if (options.onRequest) {
33
+ options.onRequest({
34
+ method: requestConfig.method,
35
+ url: cafe_utility_1.Strings.joinUrl(requestConfig.baseURL, requestConfig.url),
36
+ headers: { ...requestConfig.headers },
37
+ params: requestConfig.params,
38
+ });
39
+ }
40
+ }