Skip to content

Commit

Permalink
Catch CORS error trying to populate the genome list
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtabor committed Nov 3, 2021
1 parent 7c85a7c commit e853145
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions lib/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,22 @@ class Menu {
}

static populate_genomes(navbar) {
fetch('https://s3.amazonaws.com/igv.org.genomes/genomes.json', { mode: 'cors' })
.then(response => response.json())
.then(data => {
const menu = navbar.querySelector(".igv-dropdown[data-name='Genome'] > .igv-dropdown-content");
menu.appendChild(document.createElement('hr'));
for (const genome of data) {
menu.appendChild(Menu.create_menu_item(genome.name, (igv_instance) => {
igv_instance.loadGenome(genome);
}));
}
});
try {
fetch('https://s3.amazonaws.com/igv.org.genomes/genomes.json', {mode: 'cors'})
.then(response => response.json())
.then(data => {
const menu = navbar.querySelector(".igv-dropdown[data-name='Genome'] > .igv-dropdown-content");
menu.appendChild(document.createElement('hr'));
for (const genome of data) {
menu.appendChild(Menu.create_menu_item(genome.name, (igv_instance) => {
igv_instance.loadGenome(genome);
}));
}
});
}
catch (error) {
console.log('Cannot load genomes.json, disabling genome list functionality')
}
}

static create_menu_item(name, callback) {
Expand Down

0 comments on commit e853145

Please sign in to comment.