Removed signal from fetch as not supported in all browsers.

This commit is contained in:
orangemug 2018-09-23 21:00:17 +01:00
parent 35600c253d
commit b7fd889fcd

View file

@ -76,10 +76,9 @@ class OpenModal extends React.Component {
onStyleSelect = (styleUrl) => { onStyleSelect = (styleUrl) => {
this.clearError(); this.clearError();
const requestController = new AbortController(); let canceled;
const activeRequest = fetch(styleUrl, { const activeRequest = fetch(styleUrl, {
signal: requestController.signal,
mode: 'cors', mode: 'cors',
credentials: "same-origin" credentials: "same-origin"
}) })
@ -87,6 +86,10 @@ class OpenModal extends React.Component {
return response.json(); return response.json();
}) })
.then((body) => { .then((body) => {
if(canceled) {
return;
}
this.setState({ this.setState({
activeRequest: null, activeRequest: null,
activeRequestUrl: null activeRequestUrl: null
@ -107,7 +110,11 @@ class OpenModal extends React.Component {
}) })
this.setState({ this.setState({
activeRequest: requestController, activeRequest: {
abort: function() {
canceled = true;
}
},
activeRequestUrl: styleUrl activeRequestUrl: styleUrl
}) })
} }