When to Use
- User authentication and registration
- Form submissions and data processing
- API endpoints and webhook handlers
- E-commerce transactions and payments
What They Do
- Receive HTTP requests (GET, POST, PUT, DELETE)
- Validate and process input data
- Execute business logic
- Return responses to users
How Request Functions Work
- User makes HTTP request to your function via hub URL
- Hub routes request to your function with authentication
- Function processes request data and executes business logic
- Response returned to user with any Hub enhancements
Request Function Examples
Handle product search with filters and pagination:Sample URL:
What Ollie Hub adds:
API Endpoint
π See Hub Enhancements
π See Hub Enhancements
Enhanced Response
- β Complete pagination with navigation info
- β Enhanced product data (images, slugs, stock status)
- β Applied filters context for better UX
- β Structured, consistent response format
Best Practices
Validate Early
Always validate input data first. Return helpful error messages for invalid requests.
Handle Errors Gracefully
Use try-catch blocks and return appropriate HTTP status codes and error messages.
Keep Functions Focused
Each function should handle one specific endpoint or operation. Donβt try to do everything.
Use Proper Status Codes
Return correct HTTP status codes: 200 for success, 400 for bad input, 404 for not found, etc.
Next Steps
Best Practices
Essential patterns for building robust functions
Response Functions
Learn to customize responses with analytics and enhancements
Task Functions
Automate workflows with scheduled functions
Pro Tip: Request functions work great with Response functions to add analytics, security headers, and custom transformations automatically. Check out our Best Practices guide for implementation patterns and security tips.