...

/

Solution: Requesting Random Images from the Server

Solution: Requesting Random Images from the Server

Create a project to request a random image from the server.

Solution

The solution to the “Requesting Random Images From the Server” challenge is provided below:

export default defineEventHandler((event) => {
	const images = [
		"https://upload.wikimedia.org/wikipedia/commons/f/f1/Vue.png",
		"https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Logo_Nuxt_%282023%29.svg/456px-Logo_Nuxt_%282023%29.svg.png",
		"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Javascript_Logo.png/640px-Javascript_Logo.png",
		"https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/HTML5_logo_and_wordmark.svg/640px-HTML5_logo_and_wordmark.svg.png",
		"https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/CSS3_logo_and_wordmark.svg/640px-CSS3_logo_and_wordmark.svg.png",
	];
	const randomNumber = Math.floor(Math.random() * images.length);
	return {
		image: images[randomNumber],
	};
});
Implement your code
...