Skip to main content
InterviewHubPRO
Section Overview
Q12

Question 12 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

24%
Astro Islands & SSR (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What are Astro Endpoints (`src/pages/api/...ts`)?

senior LevelCode ExampleAstroHTTP & REST APIs

In Simple Words: Create standalone REST API endpoints that return JSON, XML, or binary data:

typescript
// src/pages/api/health.ts
import type { APIRoute } from 'astro';

export const GET: APIRoute = async () => {
  return new Response(JSON.stringify({ status: 'ok', uptime: process.uptime() }), {
    status: 200,
    headers: { 'Content-Type': 'application/json' }
  });
};