I tried to submit the HTML Form in the following ways.
- Single demo HTML File. - It works (No errors and HTTP 200 response code)
- Submitted the form using the Chrome POSTMAN plugin - It works (No errors and HTTP 200 response
But, when I am trying to submit the same form.
- Using Angular2 - Form submitted Successfully (Has Error and HTTP 200 response code)
Here is the error
XMLHttpRequest cannot load https://docs.google.com/forms/d/e/1FAIpQLSfXzWPpI4X9ghY_6p5ghJRt6DC80FnrKqlw8lUg-OT-bKzBeg/formResponse. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
I found some similar questions like 1 2 3 in SO and I now know that the error is not related to Angular2.
My question is has 2 parts.
- If this is something that has to be fixed at server side for clients to access smoothly, then how is it working when submitted directly from HTML file and POSTMAN plugin?
- When submitted using Angular2, though there is
Access-Control-Allow-Origin
error in console, the form is successfully submitted with HTTP response code 200, how should I understand this, why 200 response code, if there is an error?
Here is my angular2 code, May be it has an issue?
this._http
.post(this.postUrl, data)
.subscribe(data => {
console.log('Congrats your feedback is recorded...');
// this is not printed in console.log so far
}, error => {
console.log(error.json());
// No 'Access-Control-Allow-Origin' header is present on the requested resource.
});