jh-be-tools 1.0.20 → 1.0.22
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { AxiosError, AxiosRequestConfig } from 'axios';
|
|
1
|
+
import { AxiosError, AxiosRequestConfig, AxiosHeaders } from 'axios';
|
|
2
2
|
export interface Request {
|
|
3
3
|
path: string;
|
|
4
4
|
serviceName: string;
|
|
5
5
|
params?: AxiosRequestConfig['params'];
|
|
6
|
+
headers?: AxiosHeaders;
|
|
6
7
|
body?: unknown;
|
|
7
8
|
}
|
|
8
9
|
export interface Error {
|
|
@@ -29,6 +29,9 @@ const get = async (req) => {
|
|
|
29
29
|
return await baseQuery(req, axios_1.default.get);
|
|
30
30
|
};
|
|
31
31
|
const del = async (req) => {
|
|
32
|
+
if (req.body) {
|
|
33
|
+
throw new Error('delete requests do not work with body');
|
|
34
|
+
}
|
|
32
35
|
return await baseQuery(req, axios_1.default.delete);
|
|
33
36
|
};
|
|
34
37
|
const post = async (req) => {
|
|
@@ -42,7 +45,7 @@ const patch = async (req) => {
|
|
|
42
45
|
};
|
|
43
46
|
const baseQuery = async (req, func) => {
|
|
44
47
|
const options = {
|
|
45
|
-
headers: { 'content-type': 'application/json' },
|
|
48
|
+
headers: { 'content-type': 'application/json', ...req.headers },
|
|
46
49
|
params: req.params,
|
|
47
50
|
};
|
|
48
51
|
try {
|
|
File without changes
|