johannschopplich / nuxt-api-party

🐬 Securely connect to any API with a server proxy and generated composables
https://nuxt-api-party.byjohann.dev
MIT License
249 stars 9 forks source link

UI Freezing when uploading data through Nuxt API Party #48

Closed 9M6 closed 12 months ago

9M6 commented 1 year ago

Environment

Operating System: Darwin

Reproduction

Not applicable.

Describe the bug

 const {
        data: { value: task },
        pending,
        error,
        refresh,
      } = await useConfide("vi/api/dataset/upload", {
        method: "POST",
        body: formData,
      });

When I'm using the above function which is a wrapper and abstraction on top of the NuxtApiParty, the UI glitches and takes a bit of time to upload, in some cases crashes the browser.

https://github.com/johannschopplich/nuxt-api-party/assets/61775571/c0974eb7-71ed-42c6-ad0a-91ea4a02ea54

On the other hand, I have done another implementation with Axios and a proxy URL with routeRules, and that works completely fine, no glitches, nothing.

https://github.com/johannschopplich/nuxt-api-party/assets/61775571/c81d55c0-42d9-40e6-bd17-f7e067b9d56d

Additional context

No response

Logs

No response

johannschopplich commented 1 year ago

Quick notice: Please do not use the reactive upload handler useConfide, but $confide for simple upload handling instead. See the docs.

johannschopplich commented 1 year ago

Can you please provide a minimal reproduction?

9M6 commented 1 year ago

Hey @johannschopplich the problem is that the function in there is a simple wrapper of the Generated functions from API Party:

const cookie = useCookie("auth_c4dm");
  return useDMData<T>(
    url,
    Object.assign(
      {
        headers: {
          Authorization: `Token ${cookie.value}`,
        },
      },
      config,
    ),
  );
9M6 commented 1 year ago

As for the reproduction, I'm not sure what to provide? Like its not a bug, but more like how the library behaves. I moved that logic with Axios and everything works smooth as butter.

johannschopplich commented 1 year ago

Nuxt API Party will always generate two composables. In your case, useConfide and $confide. Please use the latter one for data sending. It won't cache results and is inteded for simple upload cases you currently use Axios for. As state earlier, please read the docs.

Please use a template below to create a minimal reproduction 👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz 👉 https://codesandbox.io/p/github/nuxt/starter/v3-codesandbox

johannschopplich commented 12 months ago

Without a reproduction, I won't be able to investigate the issue. Please open a separate issue once you found the time to create a reproducible example. Thanks in advance!