breakhours-transform/api/auth.js

33 lines
674 B
JavaScript
Raw Normal View History

2024-10-03 11:55:18 +00:00
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
}
}