23 lines
469 B
TypeScript
23 lines
469 B
TypeScript
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,
|
|
})
|
|
},
|
|
},
|
|
)
|