Due to my bad english, and my low-level. I still find nothing about it. Maybe you could help me ?
I used to use Logger.log() to test content of things I want. I'm not an experienced developer, so I don't easily get in hand way to debug my code, especially on Google Apps Script, so maybe there is tricks to bypass my issue.
the problem is simple:
function doGet(e) {
var currentUser = Session.getActiveUser().getEmail();
var ssUrl = e.parameter.url;
var sheetName = e.parameter.sheet;
var a1Notation = e.parameter.range;
As you can see, i use parameter passed by a Spreadsheet modification(well you can't see that it is a spreadsheet but you shouldn't care). But If run the script, It obviously see it as undefined and i can't try value of an object 10 lines after. I just would like to know if there is a way, such as a breakpoint, in order not to have to copy the URL String , sheet etc.. each time I need to debug.
The Script Editor offers a debugger and breakpoints, in case you haven't noticed.
In order to debug the doGet function, it's convenient to create another function that imitates a GET call. To begin with, I would create a logging web app:
function doGet(e) {
return ContentService.createTextOutput(JSON.stringify(e));
}
Then get your source of GET requests call the logging web app instead of the real one. Record the JSON string returned and use it in a function such as this one.
function fakeGet() {
var eventObject =
{
"parameter": {
"action": "view",
"page": "3"
},
"contextPath": "",
"contentLength": -1,
"queryString": "action=view&page=3",
"parameters": {
"action": ["view"],
"page": ["3"]
}
}
doGet(eventObject);
}
Here fakeGet imitates a GET request call with query string ?action=view&page=3. You can launch fakeGet from script editor and use the debugger to observe how doGet function works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With