How can I load JSON into my emails?

If you're a developer then you may want to load dynamic JSON into your emails. With Bento, this is super easy.

{% assign todos = 'https://jsonplaceholder.typicode.com/todos/1' | fetch_json %}
{% for todo in todos %}
{{ todo.title }}
{% endfor %}

The above code will fetch the JSON endpoint, return it and make it an object that you can iterate over using standard Liquid blocks. All responses are cached at the URL level for exactly 30 minutes to avoid throttling from your servers.
Leave a reply