open-index/open-npm huggingface dataset:
npm package: @oasis-end/request
Description: This is a lightweight which bases on "fetch" request library.
Author: jooies
Latest version: 1.0.24

This is a lightweight which bases on "fetch" request library.

#### Set Default Config

```typescript
import { defineDefaultConfig } from '@oasis-end/request'

defineDefaultConfig({
    method: 'post',
    baseUrl: import.env.VITE_URL,
    error(err) {
        alert(String(err))
    }
})
```

#### Modify Config Before Request

```typescript
import { onBeforeRequest } from '@oasis-end/request'

onBeforeRequest(config => {
    config.headers = new Headers(config.headers)
    config.headers.append('token', 'Bearer: test-token')
})
```

#### Use with unplugin-auto-import

```typescript
import { requestAutoImport } from '@oasis-end/request'

AutoImport({
    imports: [ requestAutoImport ]
})
```

#### Request Blob

```typescript
import { request } from '@oasis-end/request'
// res is "Blob"
const res = await request({}, 'blob')
```

#### Request ArrayBuffer

```typescript
import { request } from '@oasis-end/request'
// res is "ArrayBuffer"
const res = await request({}, 'arrayBuffer')
```