I have tried a couple of polyfill but nothing seems to be working - any suggestion, basically I am trying to post my data to a api using fetchApi - one of the main requirements is that it supports IE9 - I tried 'whatwg-fetch' but just realise it only supports IE10+ The code works in all browsers apart from IE9 and I am getting an 'Access Denied' Message. The domain api that I am posting to is different, tried the mode = 'no-cors'
Can anyone help?
import promise from 'es6-promise';
import fetch from 'isomorphic-fetch';
class PostForm extends Component {
postData(formData) {
ENDPOINT_URL = 'test/api/';
formData = {"name":"testname" , "DOB": "31/01/2018"};
promise.polyfill();
fetch(ENDPOINT_URL, {
method: 'POST',
body: JSON.stringify(formData),
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
}).then(response => response.json()).then((success) => {
alert('YES:', success); // eslint-disable-line no-alert
}).catch((error) => {
alert(error, this.state.formDataSuccess); // eslint-disable-line no-alert
});
}
handleSubmit(e) {
e.preventDefault();
this.postData();
}
export default PostForm;