diff options
| author | netop://ウィビ <paul@webb.page> | 2026-04-24 16:37:33 -0700 |
|---|---|---|
| committer | netop://ウィビ <paul@webb.page> | 2026-04-24 16:37:33 -0700 |
| commit | 510fd8cbe53abb39cba2c7cbaaefcf2783dc0066 (patch) | |
| tree | 8f753a33c475b285f2a297785d34cda3b0a8faed /source/library/fetcher/http-body.ts | |
| parent | 261f3bdb77799009344aab4a60686b7186ebd3b0 (diff) | |
| download | graphiql-510fd8cbe53abb39cba2c7cbaaefcf2783dc0066.tar.gz graphiql-510fd8cbe53abb39cba2c7cbaaefcf2783dc0066.zip | |
Implement v0.6-1.0: shortcuts, format, export/import, splitter, timing, APQ
- v0.6: matchShortcut + format(); Cmd+Shift+Enter/W/F + Cmd+Alt+arrows
- v0.7: SessionStore.exportAll/importTabs with version-1 validator
- v0.8: Splitter component + four resize handles persisted under layout.*
- v0.10: createApqFetcher (HTTP-only) wrapping shared http-body helpers
- Drop .svelte re-exports from index.ts for multi-entry JSR/npm publishing
Diffstat (limited to 'source/library/fetcher/http-body.ts')
| -rw-r--r-- | source/library/fetcher/http-body.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/library/fetcher/http-body.ts b/source/library/fetcher/http-body.ts new file mode 100644 index 0000000..b079d47 --- /dev/null +++ b/source/library/fetcher/http-body.ts @@ -0,0 +1,31 @@ + + + +/*** UTILITY ------------------------------------------ ***/ + +import type { FetcherOptions, FetcherRequest } from "./types.ts"; + +/*** EXPORT ------------------------------------------- ***/ + +export function buildHeaders(options: FetcherOptions, req: FetcherRequest): Record<string, string> { + return { + "Content-Type": "application/json", + ...options.headers, + ...req.headers + }; +} + +export async function postJson( + fetchImpl: typeof globalThis.fetch, + url: string, + headers: Record<string, string>, + body: unknown +): Promise<Record<string, unknown>> { + const response = await fetchImpl(url, { + body: JSON.stringify(body), + headers, + method: "POST" + }); + + return await response.json(); +} |