@ianwalter/http
API 的便捷包装器
安装
pnpm add @ianwalter/http
用法
import { http } from '@ianwalter/http'
// Add a new header to the global http instance.
http . options . headers = { 'csrf-token' : 'abc123' }
// Send a POST request with some data.
const response = await http . post ( '/api/thing' , { body : { complete : true } } )
拦截请求和响应
http . after = ( url , init , response ) => ( {
... response
1