johannschopplich / nuxt-api-party

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

useApiData: custom key is always `true` #55

Closed mattmess1221 closed 1 year ago

mattmess1221 commented 1 year ago

Environment

N/a

Reproduction

const nuxt = useNuxtApp()
console.log(Object.keys(nuxt.payload.data)) // []
await useApiData("...", {
  key: "somekey"
});
console.log(Object.keys(nuxt.payload.data)) // ["$apiPartytrue"]

Describe the bug

Provide a custom key to useApiData and compare nuxt.payload.data before and after. No matter what key you use, the key will be true.

This line probably got missed when changing the cache key from cache -> key. https://github.com/johannschopplich/nuxt-api-party/blob/4cc65d326edb81255689cde4d95063252efcb08d/src/runtime/composables/useApiData.ts#L125

It was also missed in $api https://github.com/johannschopplich/nuxt-api-party/blob/4cc65d326edb81255689cde4d95063252efcb08d/src/runtime/composables/%24api.ts#L86

Additional context

No response

Logs

No response

johannschopplich commented 1 year ago

Good catch!