Ganga
Ganga

Reputation: 5

How to use AJAX for GET requests in Totaljs?

I am using the below code. The AJAX GET is returning status code 500. I am not sure what is missing.

<div class="container pt-1" id="usersList">
    <h5>List of Users</h5>
    <div data-bind="users.list__template">
        <ul class="list-group">
        @{foreach user in model}
        <a class="userList" href=/@{user._id}> <li class="list-group-item">@{user.name}</li></a>
        @{end}
        </ul>
    </div>
</div> 

$('#usersListLink').on('click', (event) => {
    event.preventDefault();
    AJAX('GET /usersList', 'items --> usersList.items');
    $("#homepage").hide();
    $("#usersList").show();
    $("#addUser").hide();
});

Upvotes: 0

Views: 57

Answers (1)

fp007
fp007

Reputation: 480

It's hard to say just from what you shown. But on the controllers check the route, it looks it could be flag with some role permits.

F.route('/uesrslist', get_platform, ['authorize', '@role']);

This could be different depending on how your project is created.

Upvotes: 0

Related Questions