Skip to main content

HTTP Requests (fetch)

Often times, workers require to access data from an external resource like a website or an API. This feature allows workers to perform HTTP requests to external resources. It follows the capability-based model, so workers cannot perform any HTTP request until you configure the allowed hosts and HTTP methods.

In this configuration, you are allowing a worker to perform GET and POST HTTP requests to the {JSON} Placeholder API:

name = "fetch"
version = "1"

allowed_methods = ["GET", "POST"]
allowed_hosts = [""]

Now, your worker can perform HTTP requests following those rules.

Send HTTP requests in different languages

Depending on the language, the different kits expose this feature in a different way. The goal is to use a common API to perform HTTP requests in that language. For example, to perform HTTP requests in JavaScript you can use the fetch API.

Check these guides to perform HTTP requests in the different supported languages:

Language compatibility

LanguageHTTP Requests