postgrestx-monorepo / core/src / createFetchHttpClient
Function: createFetchHttpClient()
createFetchHttpClient(
opts
):HttpClient
Defined in: packages/core/src/postgrest/http.ts:49
Create an HttpClient backed by the Fetch API.
Automatically JSON-stringifies non-string bodies and parses JSON responses when the Content-Type
header includes application/json
.
Parameters
opts
FetchClientOptions
= {}
Returns
Examples
ts
import { createFetchHttpClient } from '@postgrestx/core'
const http = createFetchHttpClient({})
const res = await http.request({ method: 'GET', url: 'https://api.test/users' })
console.log(res.status, res.data)
ts
import fetch from 'cross-fetch'
const http = createFetchHttpClient({ fetch })