Additional API examples

Can someone point me to more detailed examples of creating API endpoints, using only twig templates? Some tutorial, maybe?

Thanks in advance.

Hi @jeraso

It is a very simple concept and is described by the documentation:

There are some extra examples of your previous post here:

Each Twig filter has more examples of its use:

Happy to help with any specific requirement. We will probably do a screencast showing how to convert the demo theme to an API soon.

2 Likes

This doesn’t handle the token authentication. Variables “user”, “session.user” or “account.user” are “null”

[session]
checkToken = 1

Request sent with axios:

axios.get('/api/account/user', {
    headers: {
        "Authorization": "Bearer " + store.user.token
    }
}).then(response => {
    console.log(response.data);
});