25 lines
640 B
TypeScript
25 lines
640 B
TypeScript
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;
|
|
}
|