I am making a POST call to a Django endpoint from and Angular 6 app. What is the current preferred method for gathering, setting and passing the required CSRF token/cookie? Right now the error message that I'm getting says:
Forbidden (403) CSRF verification failed. Request aborted.
And the code trying to make the HTTP call is simply:
export class EmailService {
constructor(private http: HttpClient) {}
sendMailgunContactMessage(subject, name, email, policyNumber, message) {
const body = {
Subject: subject,
Name: name,
Email: email,
PolicyNumber: policyNumber,
Message: message
};
return this.http.post(SharedService.contactEmailUrl, body);
}
}
This question is unique because it seeks a solution that keeps CSRF protection enabled (e.g. does not use @csrf_exempt() and does not comment out the CSRF middleware).