ワンクリックで
getting-started
Create an HTTP client with interceptors. Use when making authenticated HTTP requests from a NestJS service.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Create an HTTP client with interceptors. Use when making authenticated HTTP requests from a NestJS service.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when creating or updating api specific packages in `packages/api/*`, especially for package structure, exports, module wiring, docs, and validation.
Use when implementing or reviewing HTTP integrations inside api specific packages, especially for transport choice, timeout placement, request shaping, and error handling.
Use when configuring a shared OSRM client in NestJS APIs.
Use when configuring transactional mail delivery in NestJS APIs with @wisemen/nestjs-mail.
Use when generating CSVs in APIs.
Use when scanning NestJS providers with DiscoveryService-backed utilities.
| name | getting-started |
| description | Create an HTTP client with interceptors. Use when making authenticated HTTP requests from a NestJS service. |
Use createClient to get a fetch wrapper with a typed interceptor pipeline.
All HTTP methods return a native Response. Non-2xx responses are never thrown.
import { createClient } from '@wisemen/node-fetch'
const client = createClient({
baseUrl: 'https://api.example.com',
headers: { 'X-App': 'my-app' },
})
client.interceptors.request.use(async (req) => {
const token = await tokenStore.get()
req.headers.set('Authorization', `Bearer ${token}`)
return req
})
let refreshing = false
client.interceptors.response.use(async (res, req) => {
if (res.status !== 401 || refreshing) return res
refreshing = true
await tokenStore.refresh()
refreshing = false
const retry = new Request(req.url, { method: req.method, headers: req.headers })
return client.fetch(retry)
})
client.interceptors.error.use((err, _res, req) => {
logger.error({ url: req.url, err })
return err
})
const res = await client.get('/users')
const data = await res.json()
await client.post('/users', {
body: JSON.stringify({ name: 'Alice' }),
headers: { 'Content-Type': 'application/json' },
})
await client.delete('/users/1')
const id = client.interceptors.request.use(myFn)
client.interceptors.request.eject(id) // remove by id
client.interceptors.request.eject(myFn) // remove by reference
client.interceptors.request.update(id, newFn)
client.interceptors.request.exists(id)
client.interceptors.request.clear() // remove all