Fairs
GET /api/fairs – Fetch all business fairs
GET /api/fairs/:id – Fetch a specific fair
const express = require(‘express’);
const { google } = require(‘googleapis’);
const app = express();
const sheets = google.sheets(‘v4’);
app.get(‘/api/fairs’, async (req, res) => {
const auth = await authorize(); // Authentication logic for Google Sheets API
const response = await sheets.spreadsheets.values.get({
spreadsheetId: ‘your-spreadsheet-id’,
range: ‘Sheet1!A:F’, // Adjust to match your sheet structure
});
res.json(response.data.values); // Return the fair data as JSON
});
const authorize = () => { /* Google Sheets API auth logic */ };
app.listen(3000, () => console.log(‘Server running on port 3000’));