clasp
clasp copied to clipboard
Clasp run functionName will only output the return statement of that function ?
If I have
## Code.gs
function main () {
Logger.log("Hello World);
return "Hello Moon";
}
And I do
clasp run main
It will ouput
Hello Moon
While I want it to output
Hello World
I guess it is only outputing the return statement, that's it. Is it?
The command clasp run calls the Apps Script API scripts.run method. The behavior of this method is not controlled by clasp.
https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#response-body
As you see in the documentation, the only response from the API is going to be the return value of the function.
If you want to see log output using clasp, use console.log() instead of Logger.log() in your code, and run the clasp logs command or view the logs in a browser window.