ismx-nexo-node-app 0.3.65 → 0.3.67
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.
|
@@ -37,18 +37,16 @@ class RepositoryRest extends Repository_1.default {
|
|
|
37
37
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|
|
38
38
|
let call = fetch(this.baseUrl + endpoint + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { body: method === "GET" ? JSON.stringify(request.body) : undefined, headers }));
|
|
39
39
|
// Añade información adicional a la respuesta y devuelve el resultado (o el error en su caso).
|
|
40
|
-
return call.then((res) => {
|
|
40
|
+
return call.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
var _a, _b;
|
|
42
42
|
let headers = {};
|
|
43
43
|
res.headers.forEach((value, key) => headers[key] = value);
|
|
44
44
|
let response = {
|
|
45
|
-
httpCode: res.status,
|
|
46
|
-
content: res.json(),
|
|
47
|
-
headers
|
|
45
|
+
httpCode: res.status, content: (yield res.json()), headers
|
|
48
46
|
};
|
|
49
47
|
(_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.onResponse) === null || _b === void 0 ? void 0 : _b.call(_a, response);
|
|
50
48
|
return response;
|
|
51
|
-
}).catch((error) => {
|
|
49
|
+
})).catch((error) => {
|
|
52
50
|
var _a, _b;
|
|
53
51
|
(_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
54
52
|
throw error;
|
|
@@ -4,7 +4,7 @@ export interface Wrapper<T> {
|
|
|
4
4
|
code: string;
|
|
5
5
|
description: string;
|
|
6
6
|
data?: T;
|
|
7
|
-
|
|
7
|
+
debug?: string;
|
|
8
8
|
}
|
|
9
9
|
export default class ServiceRestFormal<Req = any, Res = any> extends ServiceRest<Req, Wrapper<Res>> {
|
|
10
10
|
constructor(method: string, endpoint?: string);
|
package/package.json
CHANGED
|
@@ -49,12 +49,10 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
// Añade información adicional a la respuesta y devuelve el resultado (o el error en su caso).
|
|
52
|
-
return call.then((res: Response) => {
|
|
52
|
+
return call.then(async (res: Response) => {
|
|
53
53
|
let headers: any = {}; res.headers.forEach((value, key) => headers[key] = value);
|
|
54
54
|
let response: HttpResponse<E> = {
|
|
55
|
-
httpCode: res.status,
|
|
56
|
-
content: res.json() as E,
|
|
57
|
-
headers
|
|
55
|
+
httpCode: res.status, content: (await res.json()) as E, headers
|
|
58
56
|
};
|
|
59
57
|
this.options?.onResponse?.(response);
|
|
60
58
|
return response;
|