I am trying to embed a mailchimp sign up form to my angular2 application.
http://kb.mailchimp.com/lists/signup-forms/add-a-signup-form-to-your-website
I am stuck at doing a http post call to mailchimp server. I am referencing the angular2 guide here: https://angular.io/docs/ts/latest/guide/server-communication.html
This is my code in the data.service.
private mailChimpUrl = 'http://us14.list-manage.com/subscribe/post?u=xxxxxxxxxxxxxxxxxx&id=xxxxxxxxxxxxxxxxx';
addSubscriber(): Observable<string> {
let body = JSON.stringify( { "EMAIL" : "abcdefg@hijk.com" } );
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
return this.http.post(this.mailChimpUrl, body, options)
.map(this.extractData)
.catch(this.handleError);
}
I understand that browser will throw an error because of CORS. I have tried to use a chrome extension plugin to try and test if the http call is working. It throws this error.
XMLHttpRequest cannot load http://us14.list-manage.com/subscribe/post?u=xxxxxxxxxxxxxxxxxx&id=xxxxxxxxxxxxxxxxx. Response for preflight has invalid HTTP status code 501
Not sure if I am doing things wrongly. Question will be is there anyway I can make it work without creating a server side call to the mailchimp server? Thanks.