Помогите найти ошибку. Имеется таблица:
<table>
<thead>
<tr>
<th>Username</th>
<th>Role</th>
<th>First name</th>
<th>Last name</th>
<th>Email</th>
<th>Notes</th>
<th>Active State</th>
</tr>
</thead>
<tbody id="user-list">
<script id="user-records" type="text/x-handlebars-template">
{{#each user}}
<tr>
<td>{{username}}</td>
<td>{{role}}</td>
<td>{{firstName}}</td>
<td>{{lastName}}</td>
<td>{{email}}</td>
<td>{{notes}}</td>
<td>{{activeState}}</td>
</tr>
{{/each}}
</script>
</tbody>
</table>
Темплейт:
var USER_METHOD ={
handlerData:function(resJSON){
var templateSource = $("#user-records").html(),
template = Handlebars.compile(templateSource),
studentHTML = template(resJSON);
$('#user-list').html(studentHTML);
},
loadUserData : function(){
$.ajax({
url:"/users",
method:'get',
success:this.handlerData
})
}
};
$(document).ready(function(){
USER_METHOD.loadUserData();
});
Ну и сам запрос:
@RestController
@RequestMapping("/users")
public class UsersController {
@Autowired
private UserRepository repo;
@RequestMapping(method=RequestMethod.GET)
public List<User> getAll() {
return repo.findAll();
}
}
Через Postman результат в таком виде:
[
{
"id": 1,
"username": "admin",
"password": "1234",
"role": "ADMIN",
"firstName": "alex",
"lastName": "тест",
"email": "alex@test.com",
"notes": "test notes",
"activeState": 1
}
]
Проблема в том что не отображается содержимое в таблице и ошибки в браузере так же нет. Помогите найти что не так. Спасибо.