From 8f248f44258966ec7331e910ede61e07ee7825a6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 11 Nov 2022 14:42:51 +0100 Subject: [PATCH] added regex to replace in method --- print-server.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/print-server.js b/print-server.js index e849720..1517898 100644 --- a/print-server.js +++ b/print-server.js @@ -105,7 +105,13 @@ class PrintServer { for (const row of res[0]) args[row.name] = row.value; try { - let methodPath = this.method.replace('{id}', args.param); + let methodPath = this.method.replace(/{\w+}/g, function(match) { + const params = {id: args.param}; + const key = match.substr(1, match.length - 2); + const value = params[key]; + return value !== undefined ? value : match; + }); + const response = await axios({ method: 'get', url: `${conf.salix.url}/api/${methodPath}?access_token=${this.token}`,