0

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;
Tholle
  • 108,070
  • 19
  • 198
  • 189
NiseNise
  • 902
  • 4
  • 15
  • 30
  • I don't think IE9 and below supports CORS. [This might give some inspiration](https://stackoverflow.com/questions/10232017/ie9-jquery-ajax-with-cors-returns-access-is-denied). – Tholle Jul 11 '18 at 11:11
  • 1
    @Tholle - thanks just gave me idea what the issue was - i assumed my polyfil should fix those issue, which I implemented in my code. – NiseNise Jul 11 '18 at 14:50

0 Answers0