PluginNet
Fetches from a website. A plugin can reach one website for each net:<domain> permission that it holds, and no other website.
Example
Section titled “Example”// 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));Methods
Section titled “Methods”fetch()
Section titled “fetch()”fetch(url, init?): Promise<NetResponse>;Fetches a URL over https. The domain of the URL must be one that the person allowed.
Parameters
Section titled “Parameters”| 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 |
- |
Returns
Section titled “Returns”Promise<NetResponse>
the status, the headers and the body as text
