mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
Get albums and put them in the select as options
This commit is contained in:
parent
81f1707835
commit
e5cd142347
@ -62,7 +62,24 @@ upload.verifyToken = function(token, reloadOnError){
|
||||
upload.prepareUpload = function(){
|
||||
|
||||
if (upload.token) {
|
||||
document.getElementById('albumDiv').style.display = 'block';
|
||||
const select = document.querySelector('select');
|
||||
axios.get('/api/albums', { headers: { token: upload.token }})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
let albums = res.data.albums;
|
||||
|
||||
if (albums.length === 0) return;
|
||||
for (let i = 0; i < albums.length; i++) {
|
||||
let opt = document.createElement('option');
|
||||
opt.value = albums[i].id;
|
||||
opt.innerHTML = albums[i].name;
|
||||
select.appendChild(opt);
|
||||
}
|
||||
document.getElementById('albumDiv').style.display = 'block';
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
})
|
||||
}
|
||||
|
||||
div = document.createElement('div');
|
||||
|
Loading…
Reference in New Issue
Block a user