el.xwx.moe/e2e/data/user.ts

18 lines
502 B
TypeScript
Raw Normal View History

import axios, { AxiosError } from "axios"
axios.defaults.baseURL = "http://localhost:3000"
2024-07-25 18:58:52 -05:00
export async function seedUser(username?: string, password?: string, name?: string) {
try {
return await axios.post("/api/v1/users", {
username: username || "test",
password: password || "password",
name: name || "Test User",
})
2024-07-25 18:58:52 -05:00
} catch (error) {
const axiosError = error as AxiosError;
if (axiosError && axiosError.response?.status === 400) return
throw error
}
}