We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
how can I access the headers of a response using nuxt-client?
Using composable "$fetch" I get directly my dto
const myResult /*MyDto*/ = await getDocument({ composable: "$fetch", path: { id: doc.id } })
Using "useAsyncData" the response is not exposed
const { data /*MyDto*/, error, status, clear, execute, refresh } = await getDocument({ composable: "useAsyncData", key: "test", path: { id: doc.id } })
The text was updated successfully, but these errors were encountered:
@lelmarir how would you do this without the codegen layer? (using Nuxt directly)
Sorry, something went wrong.
Something like this, I suppose
const endpoint = `/api/documents/${doc.id}`; const res = await fetch(endpoint); if (!res.ok) { const text = await res.text(); throw new Error(text || `HTTP ${res.status}`); } const contentDisp = res.headers.get('content-disposition') || '';
Meanwhile, I've found a dirty trick; It's not great, but it works
let filename = null; getDocument({ composable: "$fetch", path: { id: doc.id }, onResponse: response => { const contentDisposition = response.response.headers.get('Content-Disposition'); if (contentDisposition) { const filenameMatch = contentDisposition.match(/filename="(.+)"/); if (filenameMatch && filenameMatch.length > 1) { filename = filenameMatch[1]; } } } })
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
Description
Hi,
how can I access the headers of a response using nuxt-client?
Using composable "$fetch" I get directly my dto
Using "useAsyncData" the response is not exposed
The text was updated successfully, but these errors were encountered: