Skip to content

HTTP

Terminal window
carbon add plugin Http
{ "plugins": { "http": { "scope": ["https://api.example.com/v1/*"] } } }
import { http } from '@dotcarbon/plugin-http'
const response = await http.fetch('https://api.example.com/v1/items', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ name: 'Carbon' }),
})
if (response.status >= 400) throw new Error(response.body)

The result includes status, status text, headers, and a string body. Scope matching validates the full origin and path prefix rather than relying on a raw string prefix.