@weapnl/js-junction 0.0.8 → 0.0.9

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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v0.0.9
6
+ - Added option to override the config of an request.
7
+ - Added the body parameters to the post request.
8
+ - Updated the requests variable from a object to an array.
9
+
5
10
  ## v0.0.8
6
11
  - Model post requests.
7
12
  - Added onFinished callback.
package/index.d.ts CHANGED
@@ -88,6 +88,7 @@ declare class Request extends Mixins {
88
88
  onForbidden(callback?: (response: Response) => void): this;
89
89
  triggerResponseEvents(response: Response, successResponse?: any): Promise<void>;
90
90
  customParameters(parameters?: object): this;
91
+ setConfig(config: object): this;
91
92
  setApi(api: Api): this;
92
93
  }
93
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapnl/js-junction",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "This project allows you to easily consume API's built with Junction.",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
package/src/api.js CHANGED
@@ -6,7 +6,7 @@ export default class Api {
6
6
  constructor () {
7
7
  this.setHeader('X-Requested-With', 'XMLHttpRequest');
8
8
 
9
- this._requests = {};
9
+ this._requests = [];
10
10
 
11
11
  this.host('/').suffix('');
12
12
 
package/src/connection.js CHANGED
@@ -25,6 +25,10 @@ export default class Connection {
25
25
  this._api.cancelRunning(request);
26
26
  }
27
27
 
28
+ getConfig () {
29
+ return this._config;
30
+ }
31
+
28
32
  setConfig (config) {
29
33
  this._config = config;
30
34
  }
package/src/request.js CHANGED
@@ -59,6 +59,17 @@ export default class Request {
59
59
  return this;
60
60
  }
61
61
 
62
+ /**
63
+ * @param {object} config
64
+ *
65
+ * @returns {this} The current instance.
66
+ */
67
+ setConfig (config) {
68
+ this._connection.setConfig(_.merge(this._connection.getConfig(), config));
69
+
70
+ return this;
71
+ }
72
+
62
73
  /**
63
74
  * @returns {this} The current instance.
64
75
  */
@@ -98,7 +109,7 @@ export default class Request {
98
109
 
99
110
  this._response = await this._connection.post(
100
111
  url,
101
- data,
112
+ { ...data, ...this.bodyParameters },
102
113
  );
103
114
 
104
115
  await this.triggerResponseEvents(this._response);
@@ -154,7 +165,7 @@ export default class Request {
154
165
 
155
166
  this._connection.cancelRunning(this);
156
167
 
157
- this._connection.setConfig({
168
+ this.setConfig({
158
169
  headers: {
159
170
  'Content-Type': 'multipart/form-data',
160
171
  },