Files
douyin_cookie_yunsya/frontend/src/api/http.js
T
travel 9e0644095f 重构为 HTTP SSO 扫码方案并引入 Vue3 前端
移除 Playwright 浏览器自动化,改用 passport/SSO HTTP 接口获取二维码与轮询登录;后端模块化拆分,前端替换为 Vue3 SPA。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 10:47:55 +08:00

27 lines
747 B
JavaScript

import axios from 'axios'
const http = axios.create({
baseURL: import.meta.env.VITE_API_BASE || '',
headers: { 'Content-Type': 'application/json' },
timeout: 120000,
})
export async function post(path, body = {}, axiosConfig = {}) {
const { data } = await http.post(path, body, axiosConfig)
return data
}
export async function get(path, params = {}, axiosConfig = {}) {
const { data } = await http.get(path, { ...axiosConfig, params })
return data
}
export function formatApiError(err, fallback = '请求失败') {
const d = err?.response?.data
if (typeof d?.message === 'string' && d.message.trim()) return d.message
if (typeof d === 'string' && d.trim()) return d
return err?.message || fallback
}
export default http