You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm trying to loop pages, basically what I did is (ignore some custom headers):
`function fetch_orders(sheet_name) {
var ck = '****'
var cs = '****'
var website = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheet_name).getRange("B3").getValue();
var manualDate = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheet_name).getRange("B6").getValue(); // Set your order start date in spreadsheet in cell B6
var m = new Date(manualDate).toISOString();
var product = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheet_name).getRange("E3").getValue();
var stat = 'completed'`
After that the for loop
`for (var page=1;page<5;page++){
var surl = website + "/wp-json/wc/v3/orders?consumer_key=" + ck + "&consumer_secret=" + cs + "&after=" + m + "&per_page=100" + "&status=" + stat + "&search=" + product + "&page=" + page;
var url = surl
Logger.log(url)
var options =
{
"method": "GET",
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"muteHttpExceptions": true,
};
var result = UrlFetchApp.fetch(url, options);
Logger.log(result.getResponseCode())
if (result.getResponseCode() == 200) {
var params = JSON.parse(result.getContentText());
Logger.log(result.getContentText());
}`
As of right now, it works in the sense it fetches pages 1 to 5, the first page gets looped and onto the sheet and then pages-2-3-etc don't get printed to the sheet.
the for loop contains everything until the removeDuplicates function, that one is outside.
I'm not sure if I should include the removeDuplicates into the loop, I felt the loop should probably only contain the result for the JSON.parse but it didn't work so I expanded.
The text was updated successfully, but these errors were encountered:
Hi,
I'm trying to loop pages, basically what I did is (ignore some custom headers):
`function fetch_orders(sheet_name) {
After that the for loop
`for (var page=1;page<5;page++){
As of right now, it works in the sense it fetches pages 1 to 5, the first page gets looped and onto the sheet and then pages-2-3-etc don't get printed to the sheet.
the for loop contains everything until the removeDuplicates function, that one is outside.
I'm not sure if I should include the removeDuplicates into the loop, I felt the loop should probably only contain the result for the JSON.parse but it didn't work so I expanded.
The text was updated successfully, but these errors were encountered: