laravel-request 1.1.19 → 1.1.21
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 +1 -1
- package/src/Api.js +10 -0
- package/src/ApiRequest.js +1 -0
package/package.json
CHANGED
package/src/Api.js
CHANGED
|
@@ -14,6 +14,10 @@ export default class Api {
|
|
|
14
14
|
*/
|
|
15
15
|
static requestClass = ApiRequest;
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @return {Promise<string>}
|
|
20
|
+
*/
|
|
17
21
|
static tokenResolver = async () =>
|
|
18
22
|
{
|
|
19
23
|
return localStorage.getItem('api_token');
|
|
@@ -131,6 +135,11 @@ export default class Api {
|
|
|
131
135
|
return new this.requestClass(controller, action, data, 'DELETE').addArg(id);
|
|
132
136
|
}
|
|
133
137
|
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @param params
|
|
141
|
+
* @return {*}
|
|
142
|
+
*/
|
|
134
143
|
static encodeQueryString(params) {
|
|
135
144
|
const flattenObject = (obj, parentKey = '') => {
|
|
136
145
|
return Object.entries(obj).map(([key, value]) => {
|
|
@@ -144,6 +153,7 @@ export default class Api {
|
|
|
144
153
|
};
|
|
145
154
|
|
|
146
155
|
const flatParams = flattenObject(params);
|
|
156
|
+
|
|
147
157
|
return flatParams.join('&');
|
|
148
158
|
}
|
|
149
159
|
|
package/src/ApiRequest.js
CHANGED