@oasis-end/request
v1.0.24
Published
This is a lightweight which bases on "fetch" request library.
Downloads
6
Readme
This is a lightweight which bases on "fetch" request library.
Set Default Config
import { defineDefaultConfig } from '@oasis-end/request'
defineDefaultConfig({
method: 'post',
baseUrl: import.env.VITE_URL,
error(err) {
alert(String(err))
}
})
Modify Config Before Request
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
import { requestAutoImport } from '@oasis-end/request'
AutoImport({
imports: [ requestAutoImport ]
})
Request Blob
import { request } from '@oasis-end/request'
// res is "Blob"
const res = await request({}, 'blob')
Request ArrayBuffer
import { request } from '@oasis-end/request'
// res is "ArrayBuffer"
const res = await request({}, 'arrayBuffer')