We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updateInventory.gs
function updateInventory() { // Get spreadsheet from ID in URL const spreadsheetID = '1Q050KV5nT77dEtTWGhSG6hyduQXwEvKc_TVKbMAB2xo'; const spreadsheet = SpreadsheetApp.openById(spreadsheetID).getSheetByName('Sheet1'); // Collect values from spreadsheet const range = spreadsheet.getDataRange(); const values = range.getValues(); const columns = values.shift(); // Convert 2D array to map const data = values.map(row => { const rowObject = {}; for (let i = 0; i < columns.length; i++) { rowObject[columns[i]] = row[i]; } return rowObject; }); // URL of deployed app const endpointURL = "https://optixtoolkit-backend-production-abcd.up.railway.app/"; // Set up POST request for each item in the map data.forEach(item => { Logger.log(`Preparing to send: ${JSON.stringify(item)}`); const options = { method: "post", contentType: "application/json", payload: JSON.stringify({ endpoint: "post-tool", name: item.name, category: item.category, reserverID: `${item.barcodeId}`, }) }; // Submit a POST request const response = UrlFetchApp.fetch(endpointURL, options); Logger.log(response.getContentText()); }); } // Call the function function doGet(e) { updateInventory(); return ContentService.createTextOutput("Inventory update completed."); }
The updateInventory() function does the following:
updateInventory()
post-tool
name
category
reserverID
A message is logged before and after a POST request is submitted for each item.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Apps Script for toolkit backend updating
Code (
updateInventory.gs
)Purpose
Explanation
The
updateInventory()
function does the following:post-tool
to update the inventoryname
category
reserverID
Logging
A message is logged before and after a POST request is submitted for each item.
The text was updated successfully, but these errors were encountered: