Comment on page
Template syntax
The Mattermix API uses the Handlebars templating syntax to dynamically update values in HTML or CSS. For example, you could have the following in your HTML:
<p>{{title}}</p>
. The title value could be updated with the API by passing a title value in the content
object of the request body. Below is an example using the Fetch API from JavaScript:
const body = {
html: "<html><body><p>{{title}}</p></body></html>",
content: {
title: "Hello World!"
}
}
const res = await fetch("mattermix.com/api/v1/image", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.MATTERMIX_API_KEY}`
},
body: JSON.stringify(body)
});
Last modified 1yr ago