初始化模版工程
This commit is contained in:
22
http/request.ts
Normal file
22
http/request.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { HTTPClient } from '@/http'
|
||||
|
||||
const CLIENT_API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || '/api'
|
||||
|
||||
export const request = new HTTPClient(
|
||||
{
|
||||
baseURL: CLIENT_API_BASE_URL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
{
|
||||
onRequest: async config => config,
|
||||
onError: (error, config) => {
|
||||
console.error('request error', {
|
||||
method: config.method,
|
||||
url: config.url,
|
||||
error,
|
||||
})
|
||||
},
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user