简体   繁体   中英

Why is my doGet(e) function returning a null value even though i passed a parameter?

This is my first time posting in stack overflow, i would appreciate it also if you would give feedback on how to post questions properly

I am currently following this tutorial by "Learn Google Spreadsheets": Tutorial that i am following

I copied this function to test if a parameter will be passed back to the server-side script (Code.gs)

**Code.gs**
    function doGet(e) {
     Logger.log(e);
     return HtmlService.createHtmlOutputFromFile('page');
    }

I have also created a basic html file (page.html) that would be rendered once the project is deployed.

After deploying/publishing the project as a web application I added a parameter at the link published link with added name parameters at the end however after running the doGet function the log viewer is displaying null

Log Viwer

e is an argument representing an event parameter

To retrieve the parameter itself, you need to specify it - given that several request parameters can be obtained through a GET request.

Also, you need to spevidy the key of a paramter in order to retrieve the corresponding value .

In your case, you are interested in e.parameter and more specifically in e.parameter.name .

So:

    function doGet(e) {
     Logger.log(e.parameter.name);
     return HtmlService.createHtmlOutputFromFile('page');
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM