Skip to main content
Version: 0.1.2

Variable: postFetchState

Imported from @react-logic/utils

const postFetchState: FetchStateMethodPreset

POST-flavoured fetchState. Reactive by default (tracks the build callback's signal reads); .callable is the imperative companion.

// Reactive — e.g. a GraphQL query that re-fires when its input changes.
const profile = postFetchState((id = '') => ({
url: '/graphql',
body: { query: USER_QUERY, variables: { id } },
}));

// Imperative — typical mutation.
const submit = postFetchState.callable((message: string) => ({
url: '/api/comments',
body: { message },
}));
submit.fetch('hello world');