work-order-monitor/data/api/login/request.ts

25 lines
640 B
TypeScript
Raw Normal View History

2026-04-16 09:50:30 +08:00
import path from "path";
import { fileURLToPath } from "url";
import client, { saveResponse } from "../client.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export async function login() {
const username = process.env.TEST_USERNAME;
const password = process.env.TEST_PASSWORD;
const response = await client.post("/SystemUser/Login", {
Account: username,
PassWord: password,
});
saveResponse(__dirname, response.data);
const setCookie = response.headers["set-cookie"];
if (setCookie) {
client.defaults.headers.common["Cookie"] = setCookie[0].split(";")[0];
}
return response.data;
}