Skip to content

PluginNet

Fetches from a website. A plugin can reach one website for each net:<domain> permission that it holds, and no other website.

// requires the permission `net:api.example.com`
const response = await ctx.net.fetch('https://api.example.com/rates');
if (response.status === 200) ctx.log('info', response.body.slice(0, 100));
fetch(url, init?): Promise<NetResponse>;

Fetches a URL over https. The domain of the URL must be one that the person allowed.

Parameter Type Description
url string an https URL
init? { body?: string; headers?: Readonly<Record<string, string>>; method?: string; } optional method, headers and body
init.body? string -
init.headers? Readonly<Record<string, string>> -
init.method? string -

Promise<NetResponse>

the status, the headers and the body as text