This means that your Cloudflare Worker script will serve new responses directly from Cloudflare’s edge network External link icon Open external link. When a Worker receives a fetch event, the script must use event.respondWith to return the newly constructed response to the client. The handleRequest constructs a new Response with the body text "Hello worker!", as well as an explicit 200 status code. In your default index.js file, you can see that request/response pattern in action. In your terminal, create a Worker project with your desired project name for example, todos: Generate a project In this tutorial, you will use the default JavaScript template to create a Workers project. Wrangler, Cloudflare’s command-line tool for managing Worker projects, integrates with all templates so that it is even easier to start writing Workers. These are often referred to as templates, each of which emphasizes a particular use case or language. InitĬloudflare offers a collection of pre-built examples for getting started with Workers. If you would like to see the finished code for this project, find the project on GitHub External link icon Open external link and refer to the live demo External link icon Open external link to review what you will be building. How the addition of Workers KV makes this tutorial a great introduction to building full, data-driven applications.How building with Workers makes it easy to focus on writing code and ship finished products.The application data will be stored in Workers KV.īefore starting this project, you should have some experience with HTML, CSS, and JavaScript. In this tutorial, you will build a todo list application using HTML, CSS, and JavaScript. Build a todo list JAMstack application Before you startĪll of the tutorials assume you have already completed the Get started guide, which gets you set up with a Cloudflare Workers account, and the Workers CLI tool, Wrangler External link icon Open external link.
0 Comments
Leave a Reply. |