Hello, please I would like a correction/ explanation of the following code. I am trying to write a code for file download for current item in a repeater with dataset
BACKEND
import wixData from ‘wix-data’;
import {mediaManager} from ‘wix-media-backend’;
let score;
$w(“#myDataset”).onCurrentIndexChanged( (index) => {
let newIndex = index; // 3
} );
export async function process() {
(‘Courses’).onCurrentIndexChanged
.find()
.then(async(results) => {
if(results.items.length > 0) {
score = results.items;
const myFileDownloadUrl = await mediaManager.getDownloadUrl(score[0 , 90].image);
return myFileDownloadUrl;
} else {
return{success:false};
}
});
}
PAGE CODE
import wixLocationFrontend from ‘wix-location’;
import { process } from ‘backend/media’;
export function MoreButton_click(event) {
process()
.then((myFileDownloadUrl) => {
wixLocationFrontend.to(myFileDownloadUrl)
}
)
}