http Transport
http(url?) creates an HTTP transport.
import { http } from '@ivem/core'
const transport = http()Default URL Behavior
http()with no argument: useschain.rpcUrls[0]from client config.http('https://your-rpc.example'): overrides the default URL.
For mainnet, the default URL is https://api.iost.io, so passing a URL is optional.
Request Injection
transport.request = async (method, path, data) => {
const res = await fetch(`https://rpc-proxy.example/${path}`, {
method,
body: data ? JSON.stringify(data) : undefined,
headers: { 'Content-Type': 'application/json' },
})
if (!res.ok) throw new Error(await res.text())
return res.json()
}Resolution order:
- use
transport.requestwhen provided - otherwise use SDK built-in fetcher with
urlorchain.rpcUrls[0]