import { fetch } from '../../lib/fetch' export type Dispatcher = (url: string, body: object) => Promise export type StandardDispatcherConfig = { keepalive?: boolean } export default function (config?: StandardDispatcherConfig): { dispatch: Dispatcher } { function dispatch(url: string, body: object): Promise { return fetch(url, { keepalive: config?.keepalive, headers: { 'Content-Type': 'text/plain' }, method: 'post', body: JSON.stringify(body), }) } return { dispatch, } }