Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ features:
- title: Component Agnostic
details: Toast and dialog services manage lifecycle and state — you bring your own Vue components. No opinionated UI. Your design system, our plumbing.
- title: Type Safe
details: Built with TypeScript 5.9+ in strict mode. Router navigation is type-checked against your route definitions. Translation keys are validated at compile time. No stringly-typed APIs.
details: Built with TypeScript 6.0+ in strict mode. Router navigation is type-checked against your route definitions. Translation keys are validated at compile time. No stringly-typed APIs.
---

## The Packages
Expand Down
19 changes: 14 additions & 5 deletions docs/packages/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,30 @@ Other packages hook into these middleware points. `fs-loading` registers request

## File Operations

`downloadRequest` and `previewRequest` are **transport-only** — they GET an endpoint as a `Blob` and return the full `AxiosResponse<Blob>`. Neither touches the DOM. There is no browser save dialog and no object-URL management inside fs-http; the consumer owns that orchestration (fs-packages issue #59). The two names share identical transport (`responseType: 'blob'`); the separate name communicates intent (download = save-to-disk, preview = inline-display).

### Download

Downloads a file and triggers a browser save dialog:
GET a file as a `Blob`, then hand the blob to a download utility such as [`triggerDownload`](/packages/helpers) from `@script-development/fs-helpers`:

```typescript
await http.downloadRequest('/reports/annual', 'annual-report', 'application/pdf');
import {triggerDownload} from '@script-development/fs-helpers';

const response = await http.downloadRequest('/reports/annual');
triggerDownload(response.data, 'annual-report.pdf');
```

The response is the full `AxiosResponse<Blob>`, so headers (e.g. `content-type`) are available before the hand-off if you need to derive a filename or extension.

### Preview

Creates a blob URL for inline preview (images, PDFs):
GET a file as a `Blob` for inline display (images, PDFs). The consumer manages the object-URL lifecycle:

```typescript
const blobUrl = await http.previewRequest('/documents/123/preview');
// Use in an <img> or <iframe> src
const response = await http.previewRequest('/documents/123/preview');
const blobUrl = URL.createObjectURL(response.data);
// Use blobUrl in an <img> or <iframe> src; revoke when done:
// URL.revokeObjectURL(blobUrl);
```

::: warning `streamRequest` removed in 0.4.0
Expand Down