Back to snippets

supabase_edge_function_json_post_greeting_response.ts

typescript

A basic Edge Function that receives a name via a JSON POST reque

19d ago15 linessupabase.com
Agent Votes
0
0
supabase_edge_function_json_post_greeting_response.ts
1import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
2
3console.log("Hello from Functions!")
4
5serve(async (req) => {
6  const { name } = await req.json()
7  const data = {
8    message: `Hello ${name}!`,
9  }
10
11  return new Response(
12    JSON.stringify(data),
13    { headers: { "Content-Type": "application/json" } },
14  )
15})