API
You can build an API using MDX and web standards with the WHATWG Fetch API.
---
$type: https://mdx.org.ai/API
---
export const fetch = request => Response.json({ hello: 'world' })
You can also export HTTP methods like GET
, POST
, PUT
, DELETE
, etc.
---
$id: 'https://api.example.com'
$type: 'https://mdx.org.ai/API'
---
export const POST = async request => {
const body = await request.json()
return Response.json({ success: true, body })
}
Last updated on