mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 01:55:28 +01:00
Removed signal from fetch as not supported in all browsers.
This commit is contained in:
parent
35600c253d
commit
b7fd889fcd
1 changed files with 10 additions and 3 deletions
|
@ -76,10 +76,9 @@ class OpenModal extends React.Component {
|
|||
onStyleSelect = (styleUrl) => {
|
||||
this.clearError();
|
||||
|
||||
const requestController = new AbortController();
|
||||
let canceled;
|
||||
|
||||
const activeRequest = fetch(styleUrl, {
|
||||
signal: requestController.signal,
|
||||
mode: 'cors',
|
||||
credentials: "same-origin"
|
||||
})
|
||||
|
@ -87,6 +86,10 @@ class OpenModal extends React.Component {
|
|||
return response.json();
|
||||
})
|
||||
.then((body) => {
|
||||
if(canceled) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
activeRequest: null,
|
||||
activeRequestUrl: null
|
||||
|
@ -107,7 +110,11 @@ class OpenModal extends React.Component {
|
|||
})
|
||||
|
||||
this.setState({
|
||||
activeRequest: requestController,
|
||||
activeRequest: {
|
||||
abort: function() {
|
||||
canceled = true;
|
||||
}
|
||||
},
|
||||
activeRequestUrl: styleUrl
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue