breakhours-transform/api/auth.js
2024-10-03 13:55:18 +02:00

33 lines
674 B
JavaScript

export const login = async (username, password) => {
const apiProdUrl = 'https://backend.fleks.works/api/users/login/'
let schema = {
username,
password,
"user_type": "dashboard",
"breakpoint": true,
"login_from": "dashboard"
}
try {
const response = await fetch(apiProdUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(schema)
});
const data = await response.json().then((data) => {
console.log({ data })
return data
});
const token = data?.results?.token
return token
} catch (err) {
console.log(err)
return err
}
}