I have refered to the documentation given online and applied everything I could from scratch while trying to understand what each of those things are doing
Make a fetch request inside of your script's event handler to the URL https://cfw-takehome.developers.workers.dev/api/variants
, and parse the response as JSON. The response will be an array of URLs, which should be saved to a variable.
Make a fetch request to one of the two URLs, and return it as the response from the script.
For each variant page, there are a number of items on the page that can be customized. Try changing the following values inside of the variant, adding your own text or URLs:
title
: the title of the web page, displayed on the window or tab title in your browser.h1#title
: the main title of the page. By default, this displays "Variant 1" or "Variant 2"p#description
: the description paragraph on the page. By default, this displays the text "This is variant X of the take home project!".a#url
: a Call to Action link with strong emphasis on the page. Try changing this to a URL of your choice, such as your personal website, and make sure to update the text "Return to cloudflare.com" as well!
If a user visits the site and receives one of the two URLs, persist which URL is chosen in a cookie so that they always see the same variant when they return to the application. A cookie would be a great way to implement this!