Skip to content

Commit

Permalink
fix: switch to async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasLohoff committed Oct 14, 2022
1 parent eb8bf34 commit 7e07cc7
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/components/ToolMenu/LayerTree/LayerTreeContextMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const LayerTreeContextMenu: React.FC<LayerTreeContextMenuProps> = ({
});
};

const downloadLayer = (url: string) => {
const downloadLayer = async (url: string) => {
if (!layer) {
return;
}
Expand All @@ -169,16 +169,13 @@ export const LayerTreeContextMenu: React.FC<LayerTreeContextMenuProps> = ({
...getBearerTokenHeader(client?.getKeycloak())
}
};
fetch(url, reqOpts)
.then((res) => {
return res.blob();
})
.then((blob) => {
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.setAttribute('download', layer.get('name'));
a.click();
});

const res = await fetch(url, reqOpts);
const blob = await res.blob();
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.setAttribute('download', layer.get('name'));
a.click();
};

let items: ItemType[] = [{
Expand Down

0 comments on commit 7e07cc7

Please sign in to comment.