How to generate csrf token in ionic.? i m using django framework as server and wish to post data to server.
This are my error:
Forbidden (403) CSRF verification failed. Request aborted. You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties. If you have configured your browser to disable cookies, please re-enable them, at least for this site, or for 'same-origin' requests. Help Reason given for failure: CSRF cookie not set.
Here are my code:
postRequest() {
var headers = new Headers();
headers.append("Accept", 'application/json');
headers.append('Content-Type', 'application/json');
let options = new RequestOptions({ headers: headers });
let body1 = {
site: this.selectedSite,
zone: this.selectedZone,
user: this.username,
categoryType: this.problemType,
conNo:'012-8888888'}
this.http.post("http://localhost:8000/apidb/simple_upload", JSON.stringify(body1), options)
.subscribe(data => {
resolve(data);
}, error => {
console.log(error);
});}