JavaScript
async function convertMarkdown(markdown) {
const res = await fetch('https://<YOUR-PROJECT-URL>/functions/v1/convert', {
method: 'POST',
headers: {
'X-Typemail-Key': process.env.TYPEMAIL_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({ markdown, template_id: 'default' }),
});
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
return await res.json(); // { html }
}