Skip to content

Commit f4a4354

Browse files
committed
Remove empty objects from JS method calls that take no params
1 parent e50c23d commit f4a4354

File tree

1 file changed

+12
-5
lines changed
  • mopidy_api_explorer/static/js

1 file changed

+12
-5
lines changed

mopidy_api_explorer/static/js/app.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,18 @@ Handlebars.registerHelper("apiMethodCurlCall", function(apiMethod) {
5858
window.location.origin + "/mopidy/rpc";
5959
});
6060
Handlebars.registerHelper("apiMethodJsCall", function(apiMethod) {
61-
return "mopidy." + snakeToCamel(apiMethod.methodName.replace("core.", "")) +
62-
`(${JSON.stringify(apiMethod.methodData.params)}).then(` +
63-
"function(data) {\n" +
64-
" console.log(data);\n" +
65-
"});";
61+
let call = "mopidy." + snakeToCamel(apiMethod.methodName.replace("core.", ""));
62+
if (Object.keys(apiMethod.methodData.params).length > 0) {
63+
call += `(${JSON.stringify(apiMethod.methodData.params)})`;
64+
} else {
65+
call += "()";
66+
}
67+
68+
call += ".then(function(data) {\n";
69+
call += " console.log(data);\n";
70+
call += "});";
71+
72+
return call;
6673
});
6774

6875
function prepareMopidyApiToc(describeData) {

0 commit comments

Comments
 (0)