@sabuj0338/axios-friday 1.3.0 → 1.4.1
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/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +27 -6
- package/dist/index.mjs +27 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -153,6 +153,18 @@ declare class Friday {
|
|
|
153
153
|
* and return the result of that handling.
|
|
154
154
|
*/
|
|
155
155
|
put(url: URL, options?: FridayOptions): Promise<AxiosResponse<any, any> | undefined>;
|
|
156
|
+
/**
|
|
157
|
+
* This TypeScript function sends a PATCH request using Axios with specified options and handles any
|
|
158
|
+
* errors that occur.
|
|
159
|
+
* @param {URL} url - The `url` parameter in the `patch` function is a URL object that represents the
|
|
160
|
+
* URL where the PATCH request will be sent. It is used to specify the destination of the request.
|
|
161
|
+
* @param {FridayOptions} [options] - The `options` parameter in the `patch` function is an optional
|
|
162
|
+
* object that may contain the following properties:
|
|
163
|
+
* @returns The `patch` function is returning the data from the response if the request is successful.
|
|
164
|
+
* If there is an error during the request, it will handle the error using the `handleError` method
|
|
165
|
+
* and return the result of that handling.
|
|
166
|
+
*/
|
|
167
|
+
patch(url: URL, options?: FridayOptions): Promise<AxiosResponse<any, any> | undefined>;
|
|
156
168
|
/**
|
|
157
169
|
* The `delete` function sends a DELETE request to a specified URL with optional headers and body,
|
|
158
170
|
* handling errors and returning the response data.
|
package/dist/index.d.ts
CHANGED
|
@@ -153,6 +153,18 @@ declare class Friday {
|
|
|
153
153
|
* and return the result of that handling.
|
|
154
154
|
*/
|
|
155
155
|
put(url: URL, options?: FridayOptions): Promise<AxiosResponse<any, any> | undefined>;
|
|
156
|
+
/**
|
|
157
|
+
* This TypeScript function sends a PATCH request using Axios with specified options and handles any
|
|
158
|
+
* errors that occur.
|
|
159
|
+
* @param {URL} url - The `url` parameter in the `patch` function is a URL object that represents the
|
|
160
|
+
* URL where the PATCH request will be sent. It is used to specify the destination of the request.
|
|
161
|
+
* @param {FridayOptions} [options] - The `options` parameter in the `patch` function is an optional
|
|
162
|
+
* object that may contain the following properties:
|
|
163
|
+
* @returns The `patch` function is returning the data from the response if the request is successful.
|
|
164
|
+
* If there is an error during the request, it will handle the error using the `handleError` method
|
|
165
|
+
* and return the result of that handling.
|
|
166
|
+
*/
|
|
167
|
+
patch(url: URL, options?: FridayOptions): Promise<AxiosResponse<any, any> | undefined>;
|
|
156
168
|
/**
|
|
157
169
|
* The `delete` function sends a DELETE request to a specified URL with optional headers and body,
|
|
158
170
|
* handling errors and returning the response data.
|
package/dist/index.js
CHANGED
|
@@ -113,12 +113,9 @@ var Friday = class {
|
|
|
113
113
|
if (this.config.refreshTokenEndpoint == void 0) return;
|
|
114
114
|
const refreshToken = this.getRefreshToken();
|
|
115
115
|
if (refreshToken === void 0) throw new Error("Unauthorized Attempt!");
|
|
116
|
-
const res = await
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
refreshToken
|
|
120
|
-
}
|
|
121
|
-
);
|
|
116
|
+
const res = await import_axios.default.post(this.config.refreshTokenEndpoint, {
|
|
117
|
+
refreshToken
|
|
118
|
+
});
|
|
122
119
|
if (res.status != 200)
|
|
123
120
|
throw new Error("Refresh access token request failed!");
|
|
124
121
|
this.resetTokens(res);
|
|
@@ -328,6 +325,30 @@ var Friday = class {
|
|
|
328
325
|
return this.handleError(error, options);
|
|
329
326
|
}
|
|
330
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* This TypeScript function sends a PATCH request using Axios with specified options and handles any
|
|
330
|
+
* errors that occur.
|
|
331
|
+
* @param {URL} url - The `url` parameter in the `patch` function is a URL object that represents the
|
|
332
|
+
* URL where the PATCH request will be sent. It is used to specify the destination of the request.
|
|
333
|
+
* @param {FridayOptions} [options] - The `options` parameter in the `patch` function is an optional
|
|
334
|
+
* object that may contain the following properties:
|
|
335
|
+
* @returns The `patch` function is returning the data from the response if the request is successful.
|
|
336
|
+
* If there is an error during the request, it will handle the error using the `handleError` method
|
|
337
|
+
* and return the result of that handling.
|
|
338
|
+
*/
|
|
339
|
+
async patch(url, options) {
|
|
340
|
+
try {
|
|
341
|
+
return await this.axiosInstance.patch(url.href, options?.body, {
|
|
342
|
+
headers: {
|
|
343
|
+
...options?.headers,
|
|
344
|
+
...this.getAuthorizationHeader(),
|
|
345
|
+
"Content-Type": "application/json"
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
} catch (error) {
|
|
349
|
+
return this.handleError(error, options);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
331
352
|
/**
|
|
332
353
|
* The `delete` function sends a DELETE request to a specified URL with optional headers and body,
|
|
333
354
|
* handling errors and returning the response data.
|
package/dist/index.mjs
CHANGED
|
@@ -77,12 +77,9 @@ var Friday = class {
|
|
|
77
77
|
if (this.config.refreshTokenEndpoint == void 0) return;
|
|
78
78
|
const refreshToken = this.getRefreshToken();
|
|
79
79
|
if (refreshToken === void 0) throw new Error("Unauthorized Attempt!");
|
|
80
|
-
const res = await this.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
refreshToken
|
|
84
|
-
}
|
|
85
|
-
);
|
|
80
|
+
const res = await axios.post(this.config.refreshTokenEndpoint, {
|
|
81
|
+
refreshToken
|
|
82
|
+
});
|
|
86
83
|
if (res.status != 200)
|
|
87
84
|
throw new Error("Refresh access token request failed!");
|
|
88
85
|
this.resetTokens(res);
|
|
@@ -292,6 +289,30 @@ var Friday = class {
|
|
|
292
289
|
return this.handleError(error, options);
|
|
293
290
|
}
|
|
294
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* This TypeScript function sends a PATCH request using Axios with specified options and handles any
|
|
294
|
+
* errors that occur.
|
|
295
|
+
* @param {URL} url - The `url` parameter in the `patch` function is a URL object that represents the
|
|
296
|
+
* URL where the PATCH request will be sent. It is used to specify the destination of the request.
|
|
297
|
+
* @param {FridayOptions} [options] - The `options` parameter in the `patch` function is an optional
|
|
298
|
+
* object that may contain the following properties:
|
|
299
|
+
* @returns The `patch` function is returning the data from the response if the request is successful.
|
|
300
|
+
* If there is an error during the request, it will handle the error using the `handleError` method
|
|
301
|
+
* and return the result of that handling.
|
|
302
|
+
*/
|
|
303
|
+
async patch(url, options) {
|
|
304
|
+
try {
|
|
305
|
+
return await this.axiosInstance.patch(url.href, options?.body, {
|
|
306
|
+
headers: {
|
|
307
|
+
...options?.headers,
|
|
308
|
+
...this.getAuthorizationHeader(),
|
|
309
|
+
"Content-Type": "application/json"
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
} catch (error) {
|
|
313
|
+
return this.handleError(error, options);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
295
316
|
/**
|
|
296
317
|
* The `delete` function sends a DELETE request to a specified URL with optional headers and body,
|
|
297
318
|
* handling errors and returning the response data.
|
package/package.json
CHANGED