added regex to replace in method
This commit is contained in:
parent
60cbfc1730
commit
8f248f4425
|
@ -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}`,
|
||||
|
|
Loading…
Reference in New Issue