An alternate syntax to fetch() that allows function chaining to compose the entire fetch request. One can also compose partial fetcher objects to be reused in future requests.
Examples:
const userFetcher = fetcher .auth("Bearer TOPSECRET") .content("application/json") .url("/api/user"); const user = await userFetcher.get(); const updateResult = await userFetcher .body({ id: user.id, name: "New name"}) .post(); Copy
const userFetcher = fetcher .auth("Bearer TOPSECRET") .content("application/json") .url("/api/user"); const user = await userFetcher.get(); const updateResult = await userFetcher .body({ id: user.id, name: "New name"}) .post();
An alternate syntax to fetch() that allows function chaining to compose the entire fetch request. One can also compose partial fetcher objects to be reused in future requests.
Examples: