nuxt-auth-sanctum icon indicating copy to clipboard operation
nuxt-auth-sanctum copied to clipboard

[Feature] Explicit types for fetch client

Open manchenkoff opened this issue 7 months ago • 2 comments

Is your feature request related to a problem? Please describe.

Since we do not provide a full ofetch-compatible client, we should explicitly return an instance that can be configured only with supported fields.

For example, the following list of fields should not be overridden by the user to keep sanctum-related logic as is:

  • baseUrl
  • credentials
  • redirect
  • retry
  • onRequest
  • onRequestError
  • onResponse
  • onResponseError

manchenkoff avatar Apr 11 '25 21:04 manchenkoff

A bit off topic, but could you please tell me how I can use nuxt useFetch while still having all the functionality of useSanctumFetch (so that cookies etc. are automatically passed to the request)? Using useSanctumFetch I can't do something like this:

<script setup>
    const { status, data } = useFetch('api/some-api-url')
</script>

<template>
    <div v-if="status === 'pending'">Loading...</div>
</template>

projct1 avatar Apr 24 '25 23:04 projct1

Using useSanctumFetch I can't do something like this

Not sure that I get it right, but it should be possible with useSanctumFetch, please check the docs here. It exposes the same data as useAsyncData.

manchenkoff avatar Apr 24 '25 23:04 manchenkoff