mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 17:21:18 +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) => {
|
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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue