Allow only one Client at a time to fetch a file [closed]

I am using javascript fetch-api to read a random file from a folder.When two different clients need two different random files, (the random files should not be the same). How can I acheive this?