async function getIngredient()

in rest-api-google-sheets/index.js [25:45]


async function getIngredient(id) {
  const auth = await google.auth.getClient({
    scopes: ['https://www.googleapis.com/auth/spreadsheets']
  });
  const api = google.sheets({version: 'v4', auth});
  const response = await api.spreadsheets.values.get({
    spreadsheetId: '1rcj3SbeK_VcMOBrwwdAksJXQVoHTZHRzVOBO8A3X148',
    range: 'Ingredients!A:E'
  });
  for (let row of response.data.values) {
    if (row[0] == id) {
      return {
        id: row[0],
        name: row[1],
        amount: row[2],
        unit: row[3],
        warehouseLocation: row[4],
      }
    }
  }
}