Complete the code to import the Deno HTTP server module.
import { serve } from "[1]";
The Deno HTTP server module is imported from the URL ending with /http/server.ts.
Complete the code to start the Deno server listening on port 8000.
serve((req) => new Response("Hello from Edge!"), { port: [1] });
Port 8000 is the default port used in many Deno Edge function examples.
Fix the error in the response header to set JSON content type.
return new Response(JSON.stringify({ message: "Hi" }), { headers: { "Content-Type": [1] } });
The correct content type for JSON responses is application/json.
Fill both blanks to create a Deno Edge function that responds with a JSON message and status 200.
export default async function handler(req) {
return new Response(JSON.stringify({ message: "[1]" }), { status: [2], headers: { "Content-Type": "application/json" } });
}The message should be a friendly greeting and the status code 200 means success.
Fill all three blanks to create a Deno Edge function that reads a query parameter 'name' and responds with a personalized greeting in JSON.
export default async function handler(req) {
const url = new URL(req.url);
const name = url.searchParams.get("[1]") || "Guest";
const body = JSON.stringify({ greeting: `Hello, [2]!` });
return new Response(body, { status: [3], headers: { "Content-Type": "application/json" } });
}The query parameter is 'name', the greeting uses that variable, and status 200 means success.