jellydn / untypeable-wretch-demo

This is a demo project that showcases how to use the Untypeable library with Wretch to make API requests to JsonPlaceholder and display the data on a webpage.
https://untypeable-demo.productsway.com/
MIT License
3 stars 2 forks source link

support mutations (POST, PUT, PATCH, DELETE) #6

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

Possible solution is to define each method as a separate router

https://api.github.com/jellydn/untypeable-wretch-demo/blob/19696540f54abd4aac3fedabc53e4e44611a76d8/src/api-client.ts#L28


const externalApi = wretch(BASE_URL, { mode: "cors" }).errorType("json");

// TODO: support mutations (POST, PUT, PATCH, DELETE)
// Possible solution is to define each method as a separate router
export const fetcher = createTypeLevelClient<typeof fetcherRouter>(
  async (path, input) => {
    const res = externalApi.get(`${path}?${new URLSearchParams(input)}`);
github-actions[bot] commented 1 year ago

Closed in a808cdf8931167ce068ac19018fd88b7fa29605b