diff --git a/main.go b/main.go index b75d0361dd79a16a57b148a044dabdf46e483c9d..af0efbcb69289482212e8fffe26c674d9a2f1c2a 100644 --- a/main.go +++ b/main.go @@ -123,7 +123,13 @@ func buildViamAPI() string { } } - result += "ViamAPI.prototype." + packageStr + strings.Title(methodStr) + " = function(config, " + args + ") {\n" + + lastComma := "," + + if args == "" { + lastComma = "" + } + + result += "ViamAPI.prototype." + packageStr + strings.Title(methodStr) + " = function(config" + lastComma + args + ") {\n" + " return axios.post(window.API_HOST + '" + packageStr + "/" + methodStr + "', {\n" for i := 0; i < lenFields; i++ { @@ -149,7 +155,7 @@ func buildViamAPI() string { methodStr := splits[len(splits)-1] result += "ViamAPI.prototype." + packageStr + strings.Title(methodStr) + " = function(config, data) {\n" + - " return axios.post(window.API_HOST + '" + packageStr + "/" + methodStr + "', data, merge({}, this.config, config));\n" + + " return axios.post(window.API_HOST + '" + packageStr + "/" + methodStr + "', data || {}, merge({}, this.config, config));\n" + "};\n\n" } }