lepisi-pengumuman/App/Views/Data/mithril.html
Gregorio Chiko Putra 7c61498047 Modified mithril.html
Added controller for API requests
2017-09-27 16:17:03 +07:00

44 lines
942 B
HTML

{% extends "base.html" %}
{% block title %}Mithril{% endblock %}
{% block body %}
<main id="mit" class="documentation">
</main>
<script>
var root = document.getElementById('mit')
var text = ''
var rend = {
view: function() {
return m('section', [
m('h1', 'Mithril'),
m('p', text),
m('button', {
class: 'pseudo',
onclick: getdata
}, 'Click')
])
}
}
var getdata = function() {
m.request({
list: [],
method: 'GET',
url: '/api/posts',
withCredentials: true
})
.then(function(get) {
getdata.list = get.data
})
for (var i = 0; i < getdata.list.length; i++) {
text = text + getdata.list[i].judul + ' '
}
}
m.mount(root, rend)
</script>
{% endblock %}