Skip to content

Commit

Permalink
feat: get req key from param
Browse files Browse the repository at this point in the history
  • Loading branch information
yoojinko committed Dec 19, 2023
1 parent af1db3a commit dfc8be0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/controllers/serviceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ export default class ServiceController {
return await this.ain.getValue(creditHistoryPath) as creditHistories;
}

async request(serviceName: string, requestData: any) : Promise<any> {
async request(serviceName: string, requestData: any, requestKey?: string) : Promise<any> {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit dfc8be0

Please sign in to comment.