Get new lorem picsum on button click

I write this line of javascript multiple times(on a button click). The problem is that i get a random image first time and then it doesn’t change anymore. Any help, please?

document.getElementsByTagName("body")[0].style.backgroundImage = "url(";


Most probably the response is getting cached.

You can ensure that a fresh requests is created every time by appending an inconsequential time value as

document.getElementsByTagName("body")[0].style.backgroundImage = "url(" + new Date().getTime() +")";