Commit 37e42b1a authored by onny's avatar onny
Browse files

fix csrf token

parent 82a910ff
axios.defaults.xsrfCookieName = 'csrftoken'
axios.defaults.xsrfHeaderName = "X-CSRFTOKEN"
var demo = new Vue({
el: '#app',
data: {
......@@ -14,20 +17,19 @@ var demo = new Vue({
jobdescription: this.jobdescription.trim()
};
this.$http.post('http://127.0.0.1:8000/api/jobs/', newJob);
axios
.post('http://127.0.0.1:8000/api/jobs/', newJob)
},
removeJob: function (index) {
this.$http.delete('http://127.0.0.1:8000/api/jobs/'.concat(this.jobs[index].id));
axios
.delete('http://127.0.0.1:8000/api/jobs/'.concat(this.jobs[index].id));
this.jobs.splice(index, 1);
}
},
ready: function()
mounted: function()
{
this.$http.get('http://127.0.0.1:8000/api/jobs/').then(function (response) {
this.jobs = response.data;
},
function (response) {
console.log(response);
});
axios
.get('http://127.0.0.1:8000/api/jobs/')
.then(response => (this.jobs = response.data))
}
});
......@@ -40,6 +40,7 @@
<!-- Vue.JS -->
<!-- <script type="text/javascript" src="{% static 'js/vue-2.6.10.min.js' %}"></script> -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script type="text/javascript" src="{% static 'js/vue-resource-1.5.1.min.js' %}"></script>
<script type="text/javascript" src="{% static 'vuejs/djangovue.js' %}"></script>
</body>
......
......@@ -17,14 +17,14 @@
<div class="container">
<h2>Available Jobs</h2>
<p v-if="jobs.length == 0">Sorry, no jobs currently available</p>
<div v-for="job in jobs" class="job container">
<div v-for="(job, index) in jobs" class="job container">
<div class="col-sm-12">
<h3>[[ job.jobtitle ]]</h3>
</div>
<div class="col-sm-12">
<p>[[ job.jobdescription ]]</p>
<button class="btn" v-on:click="removeJob($index)"><span class="glyphicon glyphicon-trash pull-right"></span></button>
<button class="btn" v-on:click="removeJob([[ index ]])"><span class="glyphicon glyphicon-trash pull-right"></span></button>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment