mirror of
https://github.com/lemeow125/Reactnative-notesapp.git
synced 2025-04-19 00:11:25 +08:00
Commiting changes in order to pull initial_front end feature
This commit is contained in:
parent
f8af9daabc
commit
c743f6b313
1 changed files with 21 additions and 0 deletions
|
@ -0,0 +1,21 @@
|
|||
import axios from "axios";
|
||||
import {
|
||||
LoginParams,
|
||||
} from "../../Interfaces/Interfaces";
|
||||
|
||||
export function UserLogin(user: LoginParams) {
|
||||
return axios
|
||||
.post("http://localhost:8000/api/v1/accounts/token/login/", user)
|
||||
.then(async (response) => {
|
||||
localStorage.setItem("token", JSON.stringify(response.data.auth_token));
|
||||
console.log(
|
||||
"Login Success! Stored Token: ",
|
||||
JSON.parse(localStorage.getItem("token") || "{}")
|
||||
);
|
||||
return true;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("Login Failed: " + error);
|
||||
return false;
|
||||
});
|
||||
}
|
Loading…
Add table
Reference in a new issue