Netlify Function Fetch External API - Netlify-functions Typing CST Test
Loading…
Netlify Function Fetch External API — Netlify-functions Code
Fetches data from an external API and returns it.
# netlify/demo/fetch.js
const fetch = require('node-fetch');
exports.handler = async function(event, context) {
const res = await fetch('https://api.github.com');
const data = await res.json();
return {
statusCode: 200,
body: JSON.stringify(data)
};
}Netlify-functions Language Guide
Netlify Functions is a serverless framework built into the Netlify platform, allowing developers to deploy AWS Lambda functions without managing infrastructure. It focuses on simplicity, fast deployment, and seamless integration with static sites and JAMstack apps.
Primary Use Cases
- ▸Adding serverless endpoints to static sites
- ▸Form submission handling
- ▸Custom API endpoints
- ▸Webhook listeners
- ▸Background tasks and scheduled jobs
Notable Features
- ▸Tight integration with Netlify platform
- ▸Automatic scaling and zero infrastructure management
- ▸Supports JavaScript, TypeScript, and Go
- ▸Functions deployed alongside site builds
- ▸Easy invocation via HTTP requests
Origin & Creator
Netlify Functions is provided by Netlify, Inc., building on AWS Lambda, first released around 2018.
Industrial Note
Netlify Functions is ideal for front-end developers and JAMstack teams who want serverless backends tightly integrated with their sites, without needing to manage cloud infrastructure.
More Netlify-functions Typing Exercises
Simple Netlify Function (JavaScript)Netlify Function with Query ParametersNetlify Function with JSON ResponseNetlify Function with POST BodyNetlify Function with Environment VariablesNetlify Function Redirect ExampleNetlify Function Error HandlingNetlify Function Delayed ResponseNetlify Function with Custom Headers