clasp icon indicating copy to clipboard operation
clasp copied to clipboard

Clasp run functionName will only output the return statement of that function ?

Open freddieventura opened this issue 3 years ago • 1 comments

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?

freddieventura avatar Jun 07 '22 23:06 freddieventura

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.

Nu11u5 avatar Jun 08 '22 02:06 Nu11u5