diff --git a/src/controllers/serviceController.ts b/src/controllers/serviceController.ts index f5bbfbe..869fb57 100644 --- a/src/controllers/serviceController.ts +++ b/src/controllers/serviceController.ts @@ -77,12 +77,12 @@ export default class ServiceController { return await this.ain.getValue(creditHistoryPath) as creditHistories; } - async request(serviceName: string, requestData: any) : Promise { + async request(serviceName: string, requestData: any, requestKey?: string) : Promise { this.checkRunning(serviceName); const result = await new Promise(async (resolve, reject) => { - const requestKey = Date.now(); + requestKey = requestKey || Date.now().toString(); const requesterAddress = this.ain.getAddress(); - const responsePath = Path.app(serviceName).response(requesterAddress, requestKey.toString()); + const responsePath = Path.app(serviceName).response(requesterAddress, requestKey); await this.handler.subscribe(responsePath, resolve); const requestPath = Path.app(serviceName).request(requesterAddress, requestKey); const requestOp = buildSetOperation("SET_VALUE", requestPath, requestData); diff --git a/src/service.ts b/src/service.ts index 24239da..5f94786 100644 --- a/src/service.ts +++ b/src/service.ts @@ -79,9 +79,9 @@ export default class Service { * @param {string} requestData String data for request to service. * @returns {string} Response data from service. */ - async request(requestData: any) { + async request(requestData: any, requestKey?: string) { this.isLoggedIn(); - return await this.serviceController.request(this.serviceName, requestData); + return await this.serviceController.request(this.serviceName, requestData, requestKey); } /**