perf: use undici instead of axios
This commit is contained in:
parent
56539baadc
commit
5a15d50cfc
5 changed files with 59 additions and 97 deletions
20
src/http.ts
Normal file
20
src/http.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { request } from 'undici'
|
||||
|
||||
export default class HTTP {
|
||||
private readonly baseURL: string
|
||||
private readonly headers: Record<string, string>
|
||||
|
||||
constructor({
|
||||
baseURL,
|
||||
headers,
|
||||
}: { baseURL: string; headers: Record<string, string> }) {
|
||||
this.baseURL = baseURL
|
||||
this.headers = headers
|
||||
}
|
||||
|
||||
async get(url: string) {
|
||||
return request(`${new URL(url, this.baseURL)}`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue